Question

A working PhpMyAdmin Nginx Conf

Posted August 31, 2014 67.2k views

Hello.
I installed PhpMyAdmin on Ubuntu 12.04 VPS LEMP.
I can access http://example.com/phpmyadmin but when i enter the User/Password it does not work - the login page is reloaded and the password gets deleted.
Any idea on what’s wrong?
Can anyone send me a working PhpMyadmin, Nginx and PHP5.5 config?

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.

×
2 answers

The config that worked for me is that one. Note that the line fastcgi_pass could be different depending on how your php5-fpm is configured. I recommend you to try both unix:/var/run/php5-fpm.sock and 127.0.0.1:9000 values

server {
[...]
        location /phpmyadmin {
               root /usr/share/;
               index index.php index.html index.htm;
               location ~ ^/phpmyadmin/(.+\.php)$ {
                       try_files $uri =404;
                       root /usr/share/;
                       fastcgi_pass unix:/var/run/php5-fpm.sock; # or 127.0.0.1:9000
                       fastcgi_index index.php;
                       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                       include /etc/nginx/fastcgi_params;
               }
               location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                       root /usr/share/;
               }
        }
        location /phpMyAdmin {
               rewrite ^/* /phpmyadmin last;
        }
[...]
}

Source : https://www.howtoforge.com/running-phpmyadmin-on-nginx-lemp-on-debian-squeeze-ubuntu-11.04

This is my phpmyadmin working configuration with https,

server {
         listen       443;
    ssl on;
    ssl_certificate /etc/nginx/ssl/server.crt;
    ssl_certificate_key /etc/nginx/ssl/server.key;

        server_name phpmyadmin.example.loc;
        root /var/www/vhosts/pma/;
        index index.php;

        # set expiration of assets to MAX for caching
        location ~* \.(ico|css|js)(\?[0-9]+)?$ {
                expires max;
                log_not_found off;
        }


        location ~* \.php$ {
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_split_path_info ^(.+\.php)(.*)$;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
}

-Make sure to put you root path
-Make sure YOU HAVE CREATED the config file of phpmyadmin
-if you don’t want https just change the port to 80 and remove the ssl part
ssl on;
sslcertificate /etc/nginx/ssl/server.crt;
ssl
certificate_key /etc/nginx/ssl/server.key;

Submit an Answer