phpMyAdmin 404 error on Digital Ocean hosting

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?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

I’m install centos or vpssim on DO is good


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.