phpmyadmin 404 error on NGINX Ubuntu configuration

October 13, 2014 26.8k views

Hi
I configured my wordpress website with this tutorial: https://www.digitalocean.com/community/tutorials/how-to-configure-single-and-multiple-wordpress-site-settings-with-nginx

I configured server block as follow:

server {
    server_name web1.com;
    return 301 $scheme://www.web1.com$request_uri;
    }

# URL: add a permanent redirect if required.
server {
    server_name www.web1.com web1.com;
    root /home/ap/web1;
    access_log /var/log/nginx/www.web1.com.access.log;
    error_log /var/log/nginx/www.web1.com.error.log;
    include global/common.conf;
    include global/wordpress.conf;
    include global/multisite.conf;
}

server {
    server_name web2.com;
    return 301 $scheme://www.web2$request_uri;
    }
# URL: add a permanent redirect if required.
server {
    server_name www.web2.com  web2.com;
    root /home/ap/web2;
    access_log /var/log/nginx/www.web2.com.access.log;
    error_log /var/log/nginx/www.web2.com.error.log;
    include global/common.conf;
    include global/wordpress.conf;
    include global/multisite.conf;
}

And I was able to run wordpress on www.web1.com with no problem.
Then I installed phpmyadmin using this tutorial , https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-with-nginx-on-an-ubuntu-14-04-server

When I access ipaddress/phpmyadmin, it returns me to 404 wordpress page web1.com

I have looked at other fixes, but couldnt get it to work.

Please Help.

3 comments
  • also i Cant run web1.com/info.php too

  • To clarify things up,
    This is what I put under

    /etc/nginx/site-available/web1

    server {
        server_name web1.com;
        return 301 $scheme://www.web1.com$request_uri;
        }
    server {
        server_name www.web1.com web1.com;
        root /home/ap/web1;
        access_log /var/log/nginx/www.web1.com.access.log;
        error_log /var/log/nginx/www.web1.com.error.log;
        include global/common.conf;
        include global/wordpress.conf;
        include global/multisite.conf;
    
        location /phpmyadmin {
            alias /usr/share/phpmyadmin;
            index  index.php index.html index.htm;
        }
    }
    

    For /etc/nginx/site-available/web2

    server {
        server_name web2.com;
        return 301 $scheme://www.web2.com$request_uri;
        }
    
    server {
        server_name www.web2.com  web2.com;
        root /home/ap/web2;
        access_log /var/log/nginx/www.web2.com.access.log;
        error_log /var/log/nginx/www.web2.com.error.log;
        include global/common.conf;
        include global/wordpress.conf;
        include global/multisite.conf;
    
        location /phpmyadmin {
            alias /usr/share/phpmyadmin;
            index  index.php index.html index.htm;
        }
    }
    
  • For others, I am able to fix this by sudo ln -s /usr/share/phpmyadmin /home/ap/web1 . Previously, I followed tutorial and did this sudo ln -s /usr/share/phpmyadmin /usr/share/nginx/html

10 Answers

Hey All - I fixed it on my install (at least, it works, not sure if I missed something important though!) by doing this:

Go to the root of your Wordpress install (where the WP-Content, WP-Admin, WP-Includes folders are) - for me it was:

cd /var/www/html

Then enter:

sudo ln -s /usr/share/phpmyadmin

After I did this I was able to login via a browser at:

mydomain.com/phpmyadmin

Now I'll find out if I can get Solr running..LOL

Good luck!
Rob

In the phpMyAdmin tutorial you followed, you link the folder containing phpMyAdmin to the default Nginx document root.

sudo ln -s /usr/share/phpmyadmin /usr/share/nginx/html

Though your Nginx configuration for WordPress changes the document root to /home/ap/web1 and /home/ap/web2 Instead of linking it, you use an alias directive inside one of your server blocks:

server {
    server_name www.web1.com web1.com;
    root /home/ap/web1;
    access_log /var/log/nginx/www.web1.com.access.log;
    error_log /var/log/nginx/www.web1.com.error.log;
    include global/common.conf;
    include global/wordpress.conf;
    include global/multisite.conf;

    location /phpmyadmin {
        alias /usr/share/phpmyadmin;
        index  index.php index.html index.htm;
    }

}

Now you should be able to access phpMyAdmin at http://www.web1.com/phpmyadmin after restarting Nginx with service nginx restart

and when i run, sudo tail /var/log/nginx/error.log

got this msg

2014/10/14 10:27:50 [warn] 6698#0: conflicting server name "web2.com" on 0.0.0.0:80, ignored
2014/10/14 10:27:50 [warn] 6698#0: conflicting server name "web3.com" on 0.0.0.0:80, ignored
2014/10/14 10:37:15 [warn] 6727#0: duplicate MIME type "text/xsl" in /etc/nginx/nginx.conf:48
2014/10/14 10:37:15 [warn] 6727#0: conflicting server name "web1.com" on 0.0.0.0:80, ignored
2014/10/14 10:37:15 [warn] 6727#0: conflicting server name "web2.com" on 0.0.0.0:80, ignored
2014/10/14 10:37:15 [warn] 6727#0: conflicting server name "web3.com" on 0.0.0.0:80, ignored
2014/10/14 10:37:16 [warn] 6731#0: duplicate MIME type "text/xsl" in /etc/nginx/nginx.conf:48
2014/10/14 10:37:16 [warn] 6731#0: conflicting server name "web1.com" on 0.0.0.0:80, ignored
2014/10/14 10:37:16 [warn] 6731#0: conflicting server name "web2.com" on 0.0.0.0:80, ignored
2014/10/14 10:37:16 [warn] 6731#0: conflicting server name "web3.com" on 0.0.0.0:80, ignored
  • Remove the non-www URLs from each 2nd server {} block. It should look like this:

    server {
        server_name web1.com;
        return 301 $scheme://www.web1.com$request_uri;
    }
    
    # URL: add a permanent redirect if required.
    server {
        server_name www.web1.com;
        root /home/ap/web1;
        access_log /var/log/nginx/www.web1.com.access.log;
        error_log /var/log/nginx/www.web1.com.error.log;
        include global/common.conf;
        include global/wordpress.conf;
        include global/multisite.conf;
    }
    

    Do this for your virtual hosts.

    Also move the the location /phpmyadmin {} block above the 3 include directives.

  • After the change, I still get 404 error.

  • THis is what my default look like

    server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;
    
        root /usr/share/nginx/html;
        index index.php index.html index.htm;
    
        server_name server_domain_name_or_IP; #<----IP or www.web1.com?
    
        location / {
            try_files $uri $uri/ =404;
        }
    
        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root /usr/share/nginx/html;
        }
    
        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
        }
    }
    

Please do not the thread as other people would like to know why.

Did you solved it? Please let us know how so the community can profit from it.
You didn't solve it? Also please let us know!

i have the problem, the same problem. I create second server. Install LEMP and then need to install phpmyadmin. I did, but it is not work. 404 not found....and i do not understand where to find fault

Same! having this issue!
location /phpmyadmin {
alias /usr/share/phpmyadmin;
index index.php index.html index.htm;
}
isnt helping

Same here. Was there a fix or clarification for this problem? Help!

Thanks ;)

hey! i have similar problem on Example link i recently updated my php engine and now i got error like this.

  • 502 Bad Gateway usually means that php-fpm is not running. Try starting it manually:

    sudo service php5-fpm start
    

    If that doesn't work, check the log file for errors:

    sudo tail -20 /var/log/upstart/php5-fpm.log /var/log/php5-fpm.log
    

@trident37
thanks a lot. My phpmyadmin is now accessible.
but it redirects to 404 page after i login and works again when i go back.
strange but works :)

Have another answer? Share your knowledge.