How to Install phpMyAdmin on CentOS 7

October 22, 2018

Introduction

The database utility, phpMyAdmin, is used for managing MySQL databases through a graphical web-based interface. It can be configured to manage a local database (on the same system), or a remote database (over a network).

This tutorial will show you how to install phpMyAdmin and configure basic security on CentOS 7.

install phpmyadmin on centos7

Introduction

  • LAMP (Linux, Apache, MySQL, PHP) stack installed on the server.
  • Access to a sudo user account with root privileges (ability to use the sudo command).
  • The CentOS 7 operating system.
  • The YUM update manager, which is a default component of CentOS 7.
  • A command prompt with root access. To open a command prompt:  Menu > Applications > Utilities > Terminal.
  • A text editor. Vim is included with most Linux installations or you can use Nano.

Installation of phpMyAdmin on CentOS 7

Step 1: Install EPEL Repository

(If you’ve already installed EPEL, you can skip this step.)

CentOS 7 does not have access to phpMyAdmin in its default software repository. You’ll need to get access to the EPEL repository – the Extra Packages for Enterprise Linux.

Type the following at the command prompt, then hit enter:

sudo yum install -y epel-release

Once that operation finishes, it’s a good idea to refresh and update the EPEL repository:

sudo yum –y update

Step 2: Install Apache Web Server

PhpMyAdmin requires an active and running Apache web server. To install Apache on CentOS use the command:

yum install httpd -y

Verify the status of Apache by running with the command:

systemctl status httpd

You can also enter your server’s IP address in a browser and a testing screen should display:

verifying the apache service is running

Step 3: Installing phpMyAdmin on CentOS 7

To install PHPMyAdmin on CentOS, enter the command:

sudo yum -y install phpmyadmin

Once the system executes the command, PHPMyAdmin is installed and ready to launch.

Step 4: Configuring and Securing phpMyAdmin

Your new software installation includes a default Apache configuration file. You’ll want to make some changes to that configuration to prevent unauthorized access. Here are two common ways of restricting access to unauthorized users.

Restrict IP Addresses

This method can be used to grant remote access to a single workstation. By default, phpMyAdmin is configured so that the server it’s installed on has access. This change lets you allow or restrict access to specific IP addresses of different or additional computers.

The file is located at /etc/httpd/conf.d/phpMyAdmin.conf. Type the following at your command prompt:

sudo vim /etc/phpMyAdmin/config.inc.php

Inside the config file, you should see four (4) lines that refer to “Require IP” or “Allow IP.”  By default, they should be set to 127.0.0.1, which is the IP address referring to the system you are working on. To allow other systems to access this phpMyAdmin application, add (or change) these numbers to the IP address of the computer you want to grant access to.

Once you’ve made the changes, save the file.

Change Alias

Open phpMyAdmin.conf using a text editor:

sudo vim /etc/phpMyAdmin/config.inc.php

Near the top, you should see two lines:

Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin

“Alias” is how the internet will see your phpMyAdmin configuration. Since the default configuration is an easy target for bots and hackers, consider changing the alias setting. Just put a ‘#’ sign before the existing entries so the program sees them as comments, rather than instructions. Then add your own line:

Alias /MySecretLogin /usr/share/phpMyAdmin

Now, when you go to your login screen, you’ll have to type https://IP_OR_DOMAIN/MySecretLogin (or whatever you choose) to gain access.

Once you’re finished making changes, save the file.

Step 5: Restart Apache

Regardless of which configuration you use, you’ll need to restart the Apache service to see your changes:

sudo systemctl restart httpd.service

Step 6: Verify phpMyAdmin is Working

To check if phpMyAdmin is working correctly, enter your servers IP and /phpmyadmin in a web browser. For example:

125.0.0.2/phpmyadmin

You should see the PhpMyAdmin login screen.

Note: Fill in the location of your own public server information in place of “IP_OR_DOMAIN.” You’ll need to collect this information from your particular server configuration. It’ll usually be your domain name or the IP address of your server.

Conclusion

PhpMyAdmin is a widely-used application for managing databases. If followed closely, you should fine this guide on how to Install PhpMyAdmin on CentOS 7 very useful.

Was this article helpful?
YesNo
Sofija Simic
Sofija Simic is an experienced Technical Writer. Alongside her educational background in teaching and writing, she has had a lifelong passion for information technology. She is committed to unscrambling confusing IT concepts and streamlining intricate software installations.
Next you should read
How To Install PhpMyAdmin On CentOS 8
June 2, 2020

The phpMyAdmin software is used for working with MySQL databases through a graphical interface. This guide shows you how to run a CentOS 8 server with Apache, MySQL, and PHP.
Read more
How To Install MySQL On CentOS 7
February 6, 2019

MySQL is open-source and free and database management application. It forms part of the LAMP stack (Linux, Apache, MySQL, PHP). This guide will walk you through installing MySQL on CentOS 7 from third-party software repositories.
Read more
How To Install PhpMyAdmin On Ubuntu 18.04
October 22, 2018

The phpMyAdmin tool is a free application for managing a MySQL server. Many users work with Ubuntu Linux because it’s more user-friendly than other Linux distributions. Installing phpMyAdmin is helpful for Ubuntu users.
Read more
How To Back Up & Restore A MySQL Database
January 25, 2024

A MySQL database has been lost, and you’re scrambling to restore a copy from your last backup. This guide will help you to learn about the mysqldump command for creating and restoring backups.
Read more