How to install phpMyAdmin on CentOS 7

Share on Social Media

In this guide, you will learn, how to install phpMyAdmin on CentOS 7 or other Redhat based Linux distros. #centlinux #linux #mysql

What is phpMyAdmin?

phpMyAdmin is a free and open-source MySQL web interface. phpMyAdmin is developed in PHP and distributed under GNU GPL 2 license. phpMyAdmin is a portable web application and due to this reason, it become one of the most popular MySQL administration tools, especially for web hosting services.

Database administrators and developers uses phpMyAdmin to perform various tasks such as creating, modifying or deleting databases, tables, fields or rows; executing SQL statements; managing users and permissions; or monitoring database instances.

In this guide, we will install phpMyAdmin on CentOS 7 based LAMP server.

This article is about step by step installation of phpMyAdmin on CentOS 7 based LAMP Server. Hence, it does not address the usage and applications of phpMyAdmin web interface. Therefore, if you are interested to learn more about phpMyAdmin then you should read Mastering phpMyAdmin 3.4 for Effective MySQL Management (PAID LINK) by Packt Publishing.

phpMyAdmin System Requirements

According to phpMyAdmin documentation following software are required by phpMyAdmin.

  • Database – MySQL / MariaDB 5.5 or later
  • Web Server – Apache, Nginx, IIS, etc.
  • PHP – PHP 7.1.3 or later

Environment Specification

In this article, we are using the same CentOS 7 LAMP server, that we have configured in our previous post Install LAMP Stack on CentOS 7.

  • Hostname – phpmyadmin-01.example.com
  • IP Address – 192.168.116.191 / 24 
  • Operating System – CentOS 7.6

Install MariaDB on CentOS 7

Connect with phpmyadmin-01.example.com server using ssh as root user.

Required version of MariaDB 5.5 is available in CentOS 7 standard yum repositories. Therefore, we are installing it using yum command.

# yum install -y mariadb-server.x86_64

Start and enable MariaDB service.

# systemctl enable --now mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

Configure and secure MariaDB service as follows.

# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

MariaDB database has been installed on our Linux server. The password of root user, that we have set here will be used later to login on phpMyAdmin web interface.

Install Apache on CentOS 7

Apache HTTP server is also available in CentOS 7 official yum repositories. Therefore, we are installing Apache web server using yum command.

# yum install -y httpd.x86_64

Start and enable httpd.service.

# systemctl enable --now httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

Allow HTTP service in Linux firewall.

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

Apache HTTP server is installed on our Linux server.

Install PHP on CentOS 7

phpMyAdmin requires PHP 7.1.3 or later that is not available in CentOS 7 official yum repositories. Therefore, we have to install a third party yum repository for installing our required version of PHP.

We will use Remi yum repository to install PHP 7.1.3. But first, we have to install EPEL (Extra Packages for Enterprise Linux) because it is required by Remi yum repository.

# yum install -y epel-release.noarch

Install Remi yum repository as follows.

# rpm -ivh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Retrieving http://rpms.remirepo.net/enterprise/remi-release-7.rpm
warning: /var/tmp/rpm-tmp.wO9bgO: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:remi-release-7.6-2.el7.remi      ################################# [100%]

Build cache for new yum repositories.

# yum makecache fast
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                     | 5.8 kB     00:00
 * base: ftp3.isra.edu.pk
 * epel: mirror.xeonbd.com
 * extras: ftp3.isra.edu.pk
 * remi-safe: rpms.remirepo.net
 * updates: ftp3.isra.edu.pk
base                                                     | 3.6 kB     00:00
epel                                                     | 5.3 kB     00:00
extras                                                   | 3.4 kB     00:00
remi-safe                                                | 3.0 kB     00:00
updates                                                  | 3.4 kB     00:00
(1/4): epel/x86_64/group_gz                                |  88 kB   00:00
(2/4): remi-safe/primary_db                                | 1.6 MB   00:03
(3/4): epel/x86_64/primary_db                              | 6.8 MB   00:15
(4/4): epel/x86_64/updateinfo                              | 997 kB   00:35
Metadata Cache Created

Install PHP 7.2 and relevant packages.

# yum install -y php72-php php72-php-mysqlnd php72-php-gd php72-php-xml php72-php-mbstring

PHP 7.2 and relevant packages has been installed on our Linux server.

We have successfully configured a CentOS 7 based LAMP server.

Install phpMyAdmin on CentOS 7

phpMyAdmin 4.4 is available in EPEL yum repository. However, phpMyAdmin 5 has been released and available for download on their website.

If you want to use some exclusive features of phpMyAdmin 5 then you have to install it. Otherwise, phpMyAdmin 4.4 will serve the purpose of database administration as well.

Install phpMyAdmin on CentOS 7 using yum command.

# yum install -y phpmyadmin

phpMyAdmin created it’s configuration in Apache HTTP server at /etc/httpd/conf.d/phpMyAdmin.conf.

By using Apache Access Control, phpMyAdmin only allows access by localhost in its default configurations.

Therefore, we need to edit it to allow access by other network systems.

# vi /etc/httpd/conf.d/phpMyAdmin.conf

In following directive, Add a configuration below as highlighted in yellow color.

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require ip 127.0.0.1
       Require ip ::1
       Require ip 192.168.116
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>
</Directory>

Restart httpd.service to apply changes.

# systemctl restart httpd.service

Access phpMyAdmin Web UI

Browse URL http://phpmyadmin-01.example.com/phpmyadmin in client’s browser.

PHPMyAdmin Login
PHPMyAdmin Login

Login using MariaDB database credentials. We are login as root user here.

PHPMyAdmin Dashboard
PHPMyAdmin Dashboard

We are now at the phpMyAdmin dashboard.

The only databases are visible here on which user has permissions.

Since, root is the super-user of MariaDB server, therefore, it can see all databases on the server.

Recommended Online Training: Learn Bash Shell in Linux for Beginners

745772 0021

Conclusion

In this article, you have learned, how to install phpMyAdmin on CentOS 7 or other Redhat based Linux distros.

Leave a Comment