phpMyAdmin with Nginx on CentOS 7 / RHEL 7

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 guide will help you to install phpMyAdmin on CentOS 7 / RHEL 7.

Before installing phpMyAdmin, you must have LAMP installed on the server. Here is the tutorial on Installing Nginx on CentOS 7 / RHEL 7.

Installing phpMyAdmin:

I am assuming that you have completed the previous steps, phpMyAdmin is available in EPEL; so Install EPEL repository rpm.

# rpm -Uvh

Install phpMyAdmin using the following command.

# yum -y install phpmyadmin php

Configuring phpMyAdmin:

phpMyAdmin package do not put any config file for Nginx, we have to create it as per our requirement. In Nginx, virtual host file can be found in /etc/nginx/conf.d directory. Lets create file called “phpmyadmin.conf”

vi /etc/nginx/conf.d/phpMyAdmin.conf

Paste the following content into the file, do modify it as per your requirement.

 server {
listen   80;
root /usr/share/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_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin$fastcgi_script_name;

Restart the services.

# systemctl restart nginx.service
# systemctl restart php-fpm.service

Configure firewall to allow http request from the external network.

# firewall-cmd --permanent --zone=public --add-service=http
# firewall-cmd --reload

Accessing phpMyAdmin:

Now access the phpMyAdmin from the browser, url will be http://your-fqdn. Login by using root or admin user.

CentOS 7 - phpMyAdmin with Nginx Login Page
CentOS 7 – phpMyAdmin with Nginx Login Page

You will get the database page.

CentOS 7 - phpMyAdmin with Nginx Home Page
CentOS 7 – phpMyAdmin with Nginx Home Page

That’s All. Hope this helped you, we welcome your comments.


Share This Post

  • Henry

    Very nice tutorial.

    Maybe it is only me but I had to edit /etc/phpMyAdmin/ and had to set AllowNoPassword for root on True else I had no access 🙂

    But thank you for the walkthrough. I love to follow them (LEMP setup was/is also great to do!)