Tips / Nginx

How to install phpMyAdmin on Nginx

Today I will tell you how to install phpmyadmin on Nginx web server. phpmyadmin is a graphical tool to help you with the administration of MySQL servers. It’s written in php and offers a very good visual way to manipulate MySQL using a web interface.

This tutorial was made for CentOS Linux, but it can apply in the same way for any kind of system, just ensure to update your nginx and website variables to make it work with your system paths.

I will asume that you already have Nginx installed on the system. You will also need php-fpm to have phpmyadmin working on Nginx.Β Let’s begin:

Install php-fpm

yum install php-fpm -y

Configure php-fpm

Edit this line at file /etc/php-fpm.d/www.conf

listen =

and change it to be:

listen = /tmp/php5-fpm.sock

Apply the changes:

sevice php-fpm restart

Download phpmyadmin

Go to and download the lastest version, example:

mkdir /root/temp
cd /root/temp
mv phpMyAdmin-4.0.8-all-languages sqladmin
mv sqladmin /var/www/html/
cd /var/www/html/sqladmin

Edit and replace this line:

$cfg['Servers'][$i]['auth_type'] = 'cookie';

With this:

$cfg['Servers'][$i]['auth_type'] = 'http';

Configure Nginx server host

Edit nginx.conf file and add this line

    include /etc/nginx/conf.d/*.conf;

Create this file /etc/nginx/conf.d/server.conf, and add this content:

server {

    listen 80 default_server;
    access_log off;
    server_name _; 
    server_name_in_redirect off;
    root  /var/www/html;

        # access to sqladmin
        location /sqladmin {
                alias   /var/www/html/sqladmin/;
                index  index.php index.html index.htm;

# php-fpm configuration
        location ~ .php$ {
            root           /var/www/html;
            try_files $uri =404;
            fastcgi_pass   unix:/tmp/php5-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
            fastcgi_buffer_size 128k;
            fastcgi_buffers 256 4k;
            fastcgi_busy_buffers_size 256k;
            fastcgi_temp_file_write_size 256k;


Remember to replace /var/www/html with the document root you need/use for your server.

Reload Nginx to apply the changes:

service nginx reload

Test phpMyAdmin

Now open your browser and surf to http://IP/sqladmin/ and your phpmyadmin will ask you for user and password of your mysql installation, you can use root as user and the root mysql password, or any other mysql user/password.

Need to add an extra layer of security? Limit access only by authorized IP address using allow/deny rules. Example:

# access to sqladmin
location /sqladmin {
alias /var/www/html/sqladmin/;
allow your.ip.addr.ess;
deny all;
index index.php index.html index.htm;

Enjoy πŸ˜€

Popular search terms:

  • phpmyadmin nginx
  • mysql conf phpmyadmin conf download nginx
  • can myPhpAdmin connect to nginx
  • phpmyadmin nginx windows

Esteban Borges

Linux Geek, Webperf Addict, Nginx Fan. CTO @Infranetworking

  • Mike

    Great tutorial..! Thank you. πŸ™‚

  • Nittrwave

    You are great. Stackoverflow did not help me πŸ™‚ but you… Thanks a lot man.

  • Onyok

    I tried to access http://our_ip/phpmyadmin/ but it keeps on dowloading .dms file

  • Thank you,sir. That setting works great for the phpmyadmin on my server.

  • Esteria

    After an update of phpMyAdmin on Gentoo I got “Access Denied” and next “Fatal error: require_once(): Failed opening required ‘./libraries/php-gettext/”

    I manage to solve with :

    find ./phpmyadmin/ -name “*.*” -exec chmod 644 {} ;
    + adding: your_path_here/cphpmyadmin/libraries/php-gettext in the php.ini include_path variable