How To Install phpMyAdmin on Nginx

Install phpMyAdmin on Nginx

PhpMyaAdmin is the web based administration tool for managing the MySQL, MariaDB and Drizzle servers, it helps in performing databases activities such as creating, deleting ,querying , tables, columns, relations, indexes, users, permissions, etc. This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS and asume and that you already have Nginx installed on the system. You will also need php-fpm to have phpmyadmin working on Nginx.

In this tutorial we will show you how to install and configuration of phpMyaAdmin on Nginx web server on your CentOS 6 server.

Install phpMyAdmin on Nginx

Step 1. First add EPEL yum repository your system.

CentOS 6:

 rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

CentOS 7:

 rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-1.noarch.rpm

Step 2. Install phpMyAdmin using the following command.

 yum -y install phpmyadmin php

Step 3. Configure nginx to serve phpMyAdmin.

In Nginx, virtual host file can be found in /etc/nginx/conf.d directory. Lets create file called “phpmyadmin.conf”.

#nano /etc/nginx/conf.d/phpmyadmin.wpcademy.com.conf

server {
listen   80;
server_name phpmyadmin.wpcademy.com;
root /var/www/html/phpMyAdmin;
 
location / {
index  index.php;
}
 
## Images and static content is treated different
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
access_log        off;
expires           30d;
}
 
location ~ /\.ht {
deny  all;
}
 
location ~ /(libraries|setup/frames|setup/libs) {
deny all;
return 404;
}
 
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/phpMyAdmin$fastcgi_script_name;
}
}

Create required directory and enable Nginx virtual host for phpmyadmin.

 mkdir -p /var/www/html/phpMyAdmin

Step 4. Restart the services.

service nginx restart
service php-fpm restart


Step 5. Finally, test phpMyAdmin.

Now open your browser and surf to http://youripaddress/phpMyAdmin or http://yourdomin.com/phpMyAdmin 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.

phpMyAdmin-login

Congratulation’s! You have successfully installed phpMyaAdmin with Nginx. Thanks for using this tutorial for installing phpMyaAdmin on Nginx web server on Linux system. For additional help or useful information, we recommend you to check the official phpMyaAdmin web site.