Nginx: How to install and configure phpMyAdmin on CentOS 7


Step 1: Find package phpmyadmin

[root@tutorialspots ~]# yum list|grep phpMyAdmin
phpMyAdmin49.noarch                      4.9.3-1.el7.ius               @ius
phpMyAdmin.noarch                        4.4.15.10-4.el7               epel
phpMyAdmin49-httpd.noarch                4.9.3-1.el7.ius               ius
phpMyAdmin49-nginx.noarch                4.9.3-1.el7.ius               ius

Step 2: install phpmyadmin

yum install phpMyAdmin49 -y

Step 3:
Edit file /etc/nginx/nginx.conf or add file /etc/nginx/conf.d/phpMyAdmin.conf

...
server {
...
		location /phpMyAdmin {
			root /usr/share;
			index  index.php;
			
			location ~\.php$ {
				try_files $uri =404;
				fastcgi_pass 127.0.0.1:9000;
				fastcgi_index index.php;
				 
				fastcgi_connect_timeout 250;
				fastcgi_send_timeout 250;
				fastcgi_read_timeout 250;
				fastcgi_buffer_size 256k;
				fastcgi_buffers 4 256k;
				fastcgi_busy_buffers_size 256k;
				fastcgi_temp_file_write_size 256k;
				fastcgi_intercept_errors on;
				
				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;
		}
...
}
...

How to install and configure phpMyAdmin on CentOS 7

If you want to protect phpmyadmin, please read this article:

htpasswd -nb username password > /home/.pma_pass
auth_basic "phpMyAdmin Login";       
auth_basic_user_file /home/.pma_pass;

Leave a Reply