How to Install phpMyAdmin on CentOS 8

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 8 is a straightforward process. This guide will walk you through the steps of installing phpMyAdmin on CentOS 8.

How to Install phpMyAdmin on CentOS 8

1. Update the system:

sudo dnf update

2. Install the phpMyAdmin package:

sudo dnf install phpMyAdmin

3. Configure the phpMyAdmin configuration file:

sudo nano /etc/httpd/conf.d/phpMyAdmin.conf

4. Add the following lines to the configuration file:

Alias /phpMyAdmin /usr/share/phpMyAdmin

Options None

AllowOverride Limit

Require all granted

5. Restart the Apache web server:

sudo systemctl restart httpd

6. Access phpMyAdmin:

Open your web browser and go to http://your_server_ip/phpMyAdmin. You will be prompted to enter your MySQL username and password.

Introduction

PhpMyAdmin is a graphical utility for managing databases. It’s typically used to remotely manage MySQL or MariaDB databases.

This tutorial explains how to install phpMyAdmin on a CentOS 8 system.

guide for installing phpMyAdmin on CentOS version 8

Prerequisites

  • Server with CentOS 8 Linux Installed
  • Working MySQL or MariaDB database
  • Terminal window / command line (Search > terminal)
  • User account with sudo or root privileges

Step 1: Install phpMyAdmin on CentOS 8

The phpMyAdmin tool is not included in the default CentOS 8 repositories. However, the file can be download manually.

1. In a terminal window, enter the following command to download the phpMyAdmin file:

wget https://files.phpmyadmin.net/phpMyAdmin/4.9.4/phpMyAdmin-4.9.4-all-languages.zip
Download phpMyAdmin file on CentOS 8.

Note: At the time this article was written, the latest version of phpMyAdmin was 4.9.4. Please check the developer’s download page for the latest version.

2. Extract the .zip file archive:

unzip phpMyAdmin-4.9.4-all-languages.zip

3. Move the extracted files to the /usr/share/phpmyadmin directory:

sudo mv phpMyAdmin-4.9.4-all-languages.zip /usr/share/phpmyadmin

4. Change directories:

cd /usr/share/phpmyadmin

5. Rename the sample php configuration file:

sudo mv config.sample.inc.php config.inc.php

6. Open the php configuration file for editing:

sudo nano config.inc.php
phpMyAdmin configuration file.

7. Find the following line:

$cfg['blowfish_secret'] = '';

8. Edit the line and enter the new php root password between the single-quotes, as follows:

$cfg['blowfish_secret']='my_password';
Edit php root password.

9. Save the file (Ctrl+o) and close (Ctrl+x).

10. Next, create and set permissions on a temporary phpMyAdmin directory:

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

Step 2: Configure Apache for phpMyAdmin

1. Create an Apache configuration file:

sudo nano /etc/httpd/conf.d/phpmyadmin.conf

2. This creates a new, blank configuration file. Enter the following code:

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>
    <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>
   
<Directory /usr/share/phpmyadmin/setup/>
   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require all granted
     </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>

3. Save the file (Ctrl+o) and exit (Ctrl+x).

4. Finally, restart the Apache service to apply the changes made in the configuration file:

systemctl restart httpd

Note: Run systemctl status httpd to verify that Apache has restarted and is running.

Step 3: Configure SELinux and Firewall

SELinux stands for Security-Enhanced Linux. This is a kernel-level enhancement that improves security. Reconfigure this protocol for phpMyAdmin to work.

1. Start by installing the following software package:

yum –y install policycoreutils-python-utils

Some versions of CentOS 8 may already have this package installed. In that case, the output indicates it has nothing to do and you can move on to the next step.

Set up SELinux.

2. Next, enable access to the phpmyadmin directory with the following commands:

semanage fcontext –a –t httpd_sys_rw_content_t '/usr/share/phpmyadmin/'
semanage fcontext –a –t httpd_sys_rw_content_t "usr/share/phpmyadmin/tmp(/.*)?"
restorecon -Rv '/usr/share/phpmyadmin/'

The first two commands may take a moment to complete. The third command recurses through the phpmyadmin directory to apply the changes.

Adjust the Firewall to Allow Traffic

1. Create a firewall rule to allow HTTP traffic with the command:

firewall–cmd ––permanent ––add-service=http

2. Make sure to reload the firewall after making these modifications:

firewall-cmd ––reload
Create a firewall rule to allow HTTP traffic.

Step 4: Test phpMyAdmin

1. Open a web browser, and navigate to the following URL:

localhost/phpmyadmin

The browser should display the phpMyAdmin login page. However, if you attempt to log in, an error message may appear:

“The server requested an authentication method unknown to the client.”

This error occurs because MySQL 8.x upgraded the password authentication mechanism. PhpMyAdmin has not been updated yet to use this authentication method.

2. To bypass this measure, open the MySQL shell and alter the root user:

mysql –u root –p

password

ALTER USER 'root'@'localhost' IDENTIFIED WITH myswl_native_password BY 'password';

3. Replace password with the actual password you set when securing the MySQL installation.

4. Refresh the web browser phpMyAdmin page, and log in with your MySQL username and password.

Step 5: Restrict Unauthorized Access to phpMyAdmin (Optional)

You should now have a working phpMyAdmin utility. This section will help you prevent unauthorized access to sensitive databases.

Allow phpMyAdmin Only From a Specific IP Address

1. Open the phpmyadmin.conf file in a text editor (we will be using nano):

sudo nano /etc/httpd/conf.d/phpmyadmin.conf

2. Find the following sections:

Require all granted

3. Replace these lines with the following:

Require ip your_system's_ip_address
Require ip ::1

4. Save and close the file.

Note: Replace your_system’s_ip_address with the system’s actual IP address. If you have multiple systems to allow, add a line for each IP address.

Add an Extra Password Authentication

1. Create a new authentication file. In a terminal window, enter the following:

mkdir /etc/phpmyadmin
htpasswd –c /etc/phpmyadmin/.htpasswd admin

2. You are prompted to enter and confirm an admin password. Do so, and make a note of the password.

3. Next, update Apache to use .htpasswd by editing /etc/httpd/conf.d/phpmyadmin.conf as follows:

nano /etc/httpd/conf.d/phpmyadmin.conf

4. Just underneath the line labeled AddDefaultCharset UTF-8, add the following lines:

    Options +FollowSymLinks +Multiviews +Indexes

    AllowOverride None

    AuthType basic

    AuthName "Authentication Required"

    AuthUserFile /etc/phpmyadmin/.htpasswd

    Require valid-user

5. Save the file and exit.

6. Finally, restart Apache:

systemctl restart httpd

Access phpMyAdmin with Updated Credentials

1. Browse back to localhost/phpmyadmin.

2. Enter the newly-defined admin username and password.

phpMyAdmin Login Page

It should take you to the main login screen as seen at the end of the previous section.

Conclusion

You should now have a working installation of phpMyAdmin on a CentOS 8 system. Use this graphic utility to manage your MySQL databases.

How to Install phpMyAdmin on CentOS 8

phpMyAdmin is a free and open source web-based database management tool written in PHP. It is used to manage MySQL, MariaDB, and other database systems. It provides a graphical user interface to manage databases, create and modify tables, add and delete users, and more. In this tutorial, we will show you how to install phpMyAdmin on CentOS 8.

Prerequisites

  • A server running CentOS 8.
  • A root user or a user with sudo privileges.
  • A LAMP stack installed on your server.

Step 1: Install Apache and PHP

Before installing phpMyAdmin, you will need to install Apache and PHP on your server. You can do this by running the following command:

sudo dnf install httpd php php-mysqlnd

Once the installation is complete, start the Apache service and enable it to start at boot time:

sudo systemctl start httpd
sudo systemctl enable httpd

Step 2: Install phpMyAdmin

Now that Apache and PHP are installed, you can install phpMyAdmin. You can do this by running the following command:

sudo dnf install phpMyAdmin

Once the installation is complete, you can configure phpMyAdmin. To do this, you will need to edit the phpMyAdmin configuration file:

sudo nano /etc/httpd/conf.d/phpMyAdmin.conf

In the file, find the following line:

Require ip 127.0.0.1

Replace it with the following line:

Require all granted

Save and close the file, then restart the Apache service for the changes to take effect:

sudo systemctl restart httpd

Step 3: Access phpMyAdmin

Now that phpMyAdmin is installed and configured, you can access it by visiting the following URL in your web browser:

http://your_server_ip/phpMyAdmin

You will be redirected to the phpMyAdmin login page. Enter your MySQL username and password to log in.

You should now be logged in to the phpMyAdmin dashboard. You can now start managing your databases.

Conclusion

In this tutorial, we have shown you how to install phpMyAdmin on CentOS 8. You should now be able to manage your databases using the phpMyAdmin web interface.

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

Contact
San Vito Al Tagliamento 33078
Pordenone Italy
Item added to cart.
0 items - 0.00
Open chat
Scan the code
Hello 👋
Can we help you?