Install phpMyAdmin with Nginx on CentOS 7 / RHEL 7 / Fedora 27 / Fedora 26

1

phpMyAdmin is an open-source web-based administration tool for managing the MySQL, MariaDB and Drizzle servers, and 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 / Fedora 27 / 26.

Prerequisites

Before proceeding to the installation of phpMyAdmin, install LEMP stack (Nginx, MariaDB, and PHP) on the server.

READ: Install Nginx, MariaDB, and PHP-FPM on CentOS 7 / RHEL 7

READ: Install Nginx, MariaDB, and PHP-FPM on Fedora 27 / Fedora 26

In CentOS 7, we need to enable EPEL repository to download and install phpMyAdmin.

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

Install phpMyAdmin

Install phpMyAdmin using the YUM command on CentOS / RHEL and dnf command on Fedora.

### CentOS 7 / RHEL 7 ###

yum -y install phpmyadmin php

### Fedora 27 / Fedora 26 ###

dnf -y install phpmyadmin php

Configure phpMyAdmin

Since the phpMyAdmin package does not put any configuration (virtual host) file for Nginx, we have to create it manually as per our requirement. In Nginx, virtual host file can be found in /etc/nginx/conf.d directory.

Let’s create a virtual host file called “phpMyAdmin.conf” under /etc/nginx/conf.d directory.

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

Paste the following content into the file. Modify it as per your requirement.

server {
        listen   80;
        server_name phpmyadmin.itzgeek.local;
        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_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin$fastcgi_script_name;
}
}

Restart the services.

systemctl restart nginx
systemctl restart php-fpm

Configure the firewall to allow HTTP request from the external network.

firewall-cmd --permanent --add-service=http
firewall-cmd --reload

Access phpMyAdmin

Now, access the phpMyAdmin from the browser using the below URL.

http://your-fully-qualified-domain-name

Log in as the root or database user.

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

You will get the database page.

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

That’s All.

Further Reading

You might also like

Install phpMyAdmin with Nginx on CentOS 7 / RHEL 7 / Fedora 27 / Fedora 26

1