phpMyAdmin 404 error on Digital Ocean hosting

Posted February 24, 2017 3.9k views
NginxLEMPUbuntu 16.04

I’m getting a 404 error after install phpMyAdmin using Digital Ocean’s guide. I have multiple domains setup on Ubuntu running nginx. There is a phpmyadmin directory within /var/www/. The only difference from the guide was the following command:

sudo ln -s /usr/share/phpmyadmin/ /var/www

Do I need to add server block possibly? Since I have multiple domains, each of them has a separate configuration file.

Sample config file:

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/;
    index index.php index.html index.htm index.nginx-debian.html;

    server_name MY_IP_ADDRESS;

    location / {
        try_files $uri $uri/ =404;

    location /phpmyadmin {
        root     /var/www/;
        index index.php index.html;

    location ~ \.php$ {
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root/$fastcgi_script_name;
        include        fastcgi_params;
        try_files      $uri /index.php;

    location ~ /\.ht {
        deny all;

Any suggestions?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers


For the location /phpmyadmin block, you may want to use alias instead of root. You also want to set either the root or alias to the actual directory that phpMyAdmin is located in.

So if /var/www/phpmyadmin exists (even as a symlink), then you want to use:

root /var/www/phpmyadmin;


alias /var/www/phpmyadmin;

You also shouldn’t need the try_files $uri /index.php; definition in the block that handles your PHP / PHP-FPM request processing. Ideally you’d set that per block as that gives you more control over what happens within each location.

For example, WordPress may handle rewrites differently than Drupal, which will handle them differently than phpMyAdmin (if it does at all), etc.

The 404 error is resulting as index.php doesn’t exist in /var/www, which is where it’s looking when a request for /phpmyadmin is routed.

I’m install centos or vpssim on DO is good