How To Install phpMyAdmin with Nginx on CentOS 7 / RHEL 7
Abstract: virtual host files can be found in /etc/nginx/conf.d directory. Let’s create a virtual host file called phpMyAdmin.conf under /etc/nginx/conf.d direct
phpMyAdmin is an open-source web-based administration tool for managing the MySQL and MariaDB 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.
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
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.rpmInstall phpMyAdmin
In our LEMP tutorial, we used Remi repository to install PHP v7.3 on the system. So, in this tutorial also we will temporarily enable Remi repository and install PHP support packages required for phpMyAdmin.
Install phpMyAdmin using the YUM command.
yum install --enablerepo=remi-php73 phpmyadminConfigure phpMyAdmin
The phpMyAdmin rpm package does not put any configuration file for Nginx. So, we have to create a virtual host file manually as per our requirement. In Nginx, virtual host files 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 --reloadAccess phpMyAdmin
Now, access the phpMyAdmin from the browser using the below URL.
http://your-fully-qualified-domain-nameLog in as the root or database user.
Install phpMyAdmin with Nginx on CentOS 7 – phpMyAdmin Login PageYou will get the database page.
Install phpMyAdmin with Nginx on CentOS 7 – phpMyAdmin ConclusionI hope this post helped you to install phpMyAdmin on CentOS 7 to manage databases over a web browser. Please share your feedback in the comments section.