How to Install phpMyAdmin on CentOS 8

This tutorial explains the process of installing one of the most popular open-source applications for managing MySQL databases – phpMyAdmin. phpMyAdmin is a free and open-source web-based application written in PHP, used to easily manage MySQL databases through your favorite web browser instead of needing to use the MySQL command line interface.

PhpMyAdmin allows users to create, modify, rename, and delete databases, tables, or fields, execute SQL commands through the browser, import and export tables to a wide range of formats, create users and modify their privileges, and much more… Thanks to this tool, we will almost never need to use the MySQL command line again. We are going to install phpMyAdmin on a CentOS 8 VPS with Apache, MariaDB, and of course, PHP. Let’s begin.

phpMyAdmin has a long list of handy features, such as:

  • Intuitive and easy to use a web interface
  • Support for almost all MySQL operations
  • Import data from CSV and SQL
  • Export data to different formats such as CSV, SQL, XML, PDF, ISO/IEC 26300 – OpenDocument Text and Spreadsheet, Word, LATEX, and others
  • Easily administer multiple MySQL servers from a single phpMyAdmin installation
  • Creating graphics of your database layout in various formats
  • Creating complex queries using Query-by-example (QBE)
  • Searching globally in a database or a subset of it
  • Transforming stored data into any format using a set of predefined functions, like displaying BLOB-data as image or download-link
  • And many more…

1. Requirements

In order to run phpMyAdmin on your CentOS 8 VPS you need the following requirements preinstalled:

  • Web server: Apache or Nginx.
  • PHP version 7.1.3 or newer, with session support, the Standard PHP Library (SPL) extension, JSON support, and mbstring, zip and GD2 extension.
  • MySQL or MariaDB database server version 5.5 or newer.
  • CentOS 8 VPS with root access enabled. Our VPSes come with root access enabled by default.

2. Login via SSH

Login to your CentOS 8 VPS using ssh as the root user, or as a user with root permissions.

ssh root@IP_Address -p Port_number

3. Update all Packages

Once you are logged in to the server, run the following command to make sure that all installed packages are up to date:

yum -y update

4. Install the LAMP stack

As mentioned in the requirements section of the tutorial, a LAMP stack (Apache, MySQL/MariaDB and PHP) is required to run phpMyAdmin on the server.

4.1. Install Apache

We will start with installing the Apache web server, one of the most popular web servers, along with wget and unzip.

yum -y install httpd wget unzip

After the installation is completed, start the web server and enable it to start upon server boot:

systemctl start httpd
systemctl enable httpd

4.2. Install PHP

Next, install PHP along with the required PHP extensions:

yum -y install php php-common php-mbstring php-gd php-pdo php-pecl-zip php-json php-mysqlnd

4.3. Install MariaDB

And finally, complete the LAMP installation by installing the MariaDB database server:

yum -y install mariadb mariadb-server

Start the MariaDB service and set it to start on reboot:

systemctl start mariadb
systemctl enable mariadb

Run the ‘mysql_secure_installation‘ post-installation script provided by MariaDB to strengthen the security of the database server and to set a root password. You can use the following options:

Set root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Make sure that you remember the root password because you will need it to log in to phpMyAdmin.

5. Install phpMyAdmin

phpMyAdmin is not available in the official CentOS 8 repositories nor the EPEL repository, so you’ll need to download the latest release from the official phpMyAdmin website. Our commands below already have the download link for the latest version of phpMyAdmin (at the time of this article being written):

cd /opt
wget https://files.phpmyadmin.net/phpMyAdmin/5.0.2/phpMyAdmin-5.0.2-all-languages.zip
unzip phpMyAdmin-5.0.2-all-languages.zip
mv phpMyAdmin-5.0.2-all-languages /usr/share/phpmyadmin

You also need to create a tmp directory and set its proper permissions:

mkdir /usr/share/phpmyadmin/tmp
chown -R apache:apache /usr/share/phpmyadmin
chmod 777 /usr/share/phpmyadmin/tmp

Once the tmp directory is created, you need to create an Apache configuration file for phpMyAdmin to be served through that web server:

vi /etc/httpd/conf.d/phpmyadmin.conf

Add the following content to that phpmyadmin.conf file:

Alias /phpmyadmin /usr/share/phpmyadmin
 
<Directory /usr/share/phpmyadmin/>
   AddDefaultCharset UTF-8
   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
      Require all granted
     </RequireAny>
   </IfModule>
</Directory>
 
<Directory /usr/share/phpmyadmin/setup/>
   <IfModule mod_authz_core.c>
 # Apache 2.4
     <RequireAny>
       Require all granted
     </RequireAny>
   </IfModule>
</Directory>

Change the directory to /usr/share/phpmyadmin and create config.inc.php:

cd /usr/share/phpmyadmin
cp config.sample.inc.php config.inc.php

Edit the newly created config.inc.php:

vi config.inc.php

Change the blowfish secret to your own secret. The secret needs to be 32 characters long:

$cfg['blowfish_secret'] = 'your-blowfish-secret';

Restart the Apache service in order for all changes including the phpMyAdmin configuration file to be loaded:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS
systemctl restart httpd

Now that this is done, the installation of phpMyAdmin is finally completed. You can now access the application and start working on your databases at http://IP_Address/phpmyadmin:

Installing phpMyAdmin on CentOS 7

If you want phpMyAdmin to be accessible from everywhere or just from a certain IP address, open its Apache configuration file and add/edit the following lines accordingly:

vi /etc/httpd/conf.d/phpmyadmin.conf

     <RequireAny>
      Require ip IP_Address
      Require ip 127.0.0.1
      Require ip ::1
     </RequireAny>

Where IP_Address is the actual IP address.

6. Restart Apache web server

Save the changes and restart the Apache web server for the changes to take effect.

systemctl restart httpd

For more information on how to configure and use phpMyAdmin, please check their official documentation at https://www.phpmyadmin.net/docs/.


Of course, you don’t have to install phpMyAdmin on CentOS 8 VPS if you use one of our Managed PHP Hosting services, in which case you can simply ask our expert Linux admins to install phpMyAdmin for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post on how to install phpMyAdmin on CentOS 8, please share it with your friends on the social networks using the buttons below or simply leave a comment in the comments section. Thanks.

Leave a Comment