Introduction
phpMyAdmin is a free and open source web-based database management tool written in PHP. It is used to manage MySQL and MariaDB databases. It provides a graphical user interface to manage databases, create and modify tables, fields, and indexes, manage users and permissions, and much more. Installing phpMyAdmin on CentOS 7 is a simple process that can be completed in a few steps. In this guide, we will show you how to install phpMyAdmin on CentOS 7.
How to Install phpMyAdmin on CentOS 7
1. Update the system:
Before installing any package it is recommended that you update the system and packages using the following command:
sudo yum update -y
2. Install the EPEL repository:
The EPEL repository is required to install phpMyAdmin. To install it, run the following command:
sudo yum install epel-release
3. Install phpMyAdmin:
Once the EPEL repository is installed, you can install phpMyAdmin using the following command:
sudo yum install phpmyadmin
4. Configure phpMyAdmin:
Once the installation is complete, you need to configure phpMyAdmin. To do this, edit the phpMyAdmin configuration file using the following command:
sudo nano /etc/httpd/conf.d/phpMyAdmin.conf
5. Restart Apache:
Once you have configured phpMyAdmin, you need to restart Apache for the changes to take effect. To do this, run the following command:
sudo systemctl restart httpd
6. Access phpMyAdmin:
Once Apache is restarted, you can access phpMyAdmin by visiting http://your_server_ip/phpmyadmin in your web browser.
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.
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:
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.
How to Install phpMyAdmin on CentOS 7
phpMyAdmin is a free and open source web-based database management tool written in PHP. It provides a graphical user interface to manage MySQL and MariaDB databases. It is one of the most popular tools used by web developers and system administrators to manage databases.
In this tutorial, we will show you how to install phpMyAdmin on a CentOS 7 system. We will also show you how to secure the phpMyAdmin installation with an SSL certificate.
Prerequisites
Before you begin with this guide, you should have a separate, non-root user account with sudo privileges set up on your server. You can learn how to set up a user account by following our Initial Server Setup with CentOS 7 guide.
Step 1 — Installing phpMyAdmin
The phpMyAdmin package is included in the default CentOS 7 repositories. We can install it by running the following command:
sudo yum install phpmyadmin
During the installation, you will be asked to select an authentication type for phpMyAdmin. Select Apache from the list by pressing the SPACEBAR and then TAB to select OK. Then press ENTER to continue.
Next, you will be asked to configure the database for phpMyAdmin with dbconfig-common. Select Yes and press ENTER to continue.
You will then be asked to provide the password of the database administrator. Enter the password and press ENTER to continue.
Once the installation is complete, you can proceed to the next step.
Step 2 — Configuring Apache for phpMyAdmin
Now that phpMyAdmin is installed, we need to configure Apache to be able to access it. We can do this by creating an Apache virtual host file.
Create a new virtual host file by running the following command:
sudo nano /etc/httpd/conf.d/phpMyAdmin.conf
Add the following lines to the file:
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
AddDefaultCharset UTF-8
# Apache 2.4
Require ip 127.0.0.1
Require ip ::1
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
# Apache 2.4
Require ip 127.0.0.1
Require ip ::1
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
# These directories do not require access over HTTP - taken from the original
# phpMyAdmin upstream tarball
#
Order Deny,Allow
Deny from All
Allow from None
Order Deny,Allow
Deny from All
Allow from None
Order Deny,Allow
Deny from All
Allow from None
# This configuration prevents mod_security at phpMyAdmin directories from
# filtering SQL etc. This may break your mod_security implementation.
# Uncomment the following line if you don't use mod_security.
#
#
# SecRuleInheritance Off
#
#
Save and close the file when you are finished.
Next, we need to enable the Apache rewrite module. We can do this by running the following command:
sudo a2enmod rewrite
Finally, restart Apache for the changes to take effect:
sudo systemctl restart httpd
Step 3 — Securing phpMyAdmin with SSL
By default, phpMyAdmin is accessible over plain HTTP. To increase the security of your phpMyAdmin installation, you can configure it to be accessible over an encrypted connection using SSL.
To do this, you will need to obtain an SSL certificate. You can get a free SSL certificate from Let’s Encrypt.
Once you have obtained the SSL certificate, you can configure Apache to use it. Create a new virtual host file by running the following command:
sudo nano /etc/httpd/conf.d/phpMyAdmin-ssl.conf
Add the following lines to the file, replacing the paths to the certificate and key files with the paths to your own certificate and key files:
Listen 443 https
ServerAdmin [email protected]
DocumentRoot /usr/share/phpMyAdmin
ServerName example.com
SSLEngine on
SSLCertificateFile /path/to/certificate.crt
SSLCertificateKeyFile /path/to/private.key
Options FollowSymLinks
DirectoryIndex index.php
AllowOverride All
Require all granted
Save and close the file when you are finished.
Next, enable the Apache SSL module by running the following command:
sudo a2enmod ssl
Finally, restart Apache for the changes to take effect:
sudo systemctl restart httpd
Conclusion
In this tutorial, we have shown you how to install and secure phpMyAdmin on a CentOS 7 server. You should now be able to access phpMyAdmin from your web browser using the secure HTTPS protocol.