This is another way to run phpMyAdmin on Nginx.

1. Install phpMyAdmin on Nginx:

apt-get install phpmyadmin

When the pop up shows up, select neither Apache or Lighttpd. You don’t need any to run phpMyAdmin on Nginx.

Screen Shot 2013-03-29 at 12.34.34 AM

And say select NO for the Configure database for phpmyadmin with dbconfig-common:

Screen Shot 2013-03-29 at 12.34.20 AM

2. Configure phpMyAdmin to work with Nginx:

Add the followings to /etc/nginx/sites-available/default file after the server{ statement:

 location /phpmyadmin {
               root /usr/share/;
               index index.php index.html index.htm;
               location ~ ^/phpmyadmin/(.+\.php)$ {
                       try_files $uri =404;
                       root /usr/share/;
                       fastcgi_index index.php;
                       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                       include /etc/nginx/fastcgi_params;
               location ~* ^/phpmyadmin/(.+\.(jpeg|jpg|png|css|gif|ico|js|html|xml|txt))$ {
                       root /usr/share/;
        location /phpMyAdmin {
               rewrite ^/* /phpmyadmin last;

3. Restart the Nginx Web Server now

/etc/init.d/nginx restart
[ ok ] Restarting nginx: nginx.

Now you can try in your browser:


Optionally you can add the configuration to any virtual host from your Nginx configuration.


Posts Twitter Facebook

Editor in Chief at Debian-Tutorials, Linux enthusiast.

3 responses to How to run phpMyAdmin on Nginx

  1. i got 502 Bad Gateway.
    logs said it must be fastcgi service on 9000 port, but it doesn’t.
    please, make sure your tutorial is complete.

  2. This tutorial is complete!

  3. jean pierre vitulli March 28, 2016 at 15:04

    no, not really complete: doesn’t work if using php-fpm.
    just replace the “location ~ ^/phpmyadmin/(.+\.php)$ {” bloc with this one.

    location ~ ^/phpmyadmin/(.+\.php)$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    well … works for me.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.