How to Install and configure phpMyAdmin in CentOS 8 / RHEL 8 Linux

by Jay

phpMyAdmin

A GUI-based programme called phpMyAdmin is used to administer MySQL databases. Databases and tables can be manually created, and queries can be run against them. It may operate on any server and offers a web-based user interface. We are able to access it from any computer because it is web-based.

Install PhpMyAdmin

Official RHEL 8.x, CentOS 8.x, and Rocky Linux 8.x repositories don’t provide any binary packages for the PhpMyAdmin Web Interface. If you are uncomfortable using the MySQL command line to manage your database, you can install the PHPMyAdmin package by enabling remi repositories using the following command:

For Centos 8, RHEL 8, Rocky Linux and AlmaLinux 8

# yum install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

For Centos 7, RHEL 7

# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# wget https://rpms.remirepo.net/enterprise/remi-release-7.rpm
# rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm

### for RHEL only ###
# subscription-manager repos --enable=rhel-7-server-optional-rpms

For RHEL 9, AlmaLinux 9, Rocky Linux 9

# yum install https://rpms.remirepo.net/enterprise/remi-release-9.rpm

After enabling remi repo, use the following command to Install phpMyAdmin

[root@web ~]# yum install phpmyadmin
Last metadata expiration check: 0:04:36 ago on Mon 03 Apr 2023 11:19:36 AM EDT.
Dependencies resolved.
=============================================================================================================
 Package              Architecture   Version                                         Repository         Size
=============================================================================================================
Installing:
 phpMyAdmin           noarch         5.2.1-1.el8.remi                                remi              8.9 M
Installing dependencies:
 libzip               x86_64         1.5.1-2.module+el8.4.0+413+c9202dda             appstream          61 k
 php-gd               x86_64         7.2.24-1.module+el8.4.0+413+c9202dda            appstream          83 k
 php-intl             x86_64         7.2.24-1.module+el8.4.0+413+c9202dda            appstream         191 k
 php-json             x86_64         7.2.24-1.module+el8.4.0+413+c9202dda            appstream          72 k
 php-mbstring         x86_64         7.2.24-1.module+el8.4.0+413+c9202dda            appstream         579 k
 php-pecl-zip         x86_64         1.15.3-1.module+el8.4.0+413+c9202dda            appstream          49 k
 php-process          x86_64         7.2.24-1.module+el8.4.0+413+c9202dda            appstream          83 k
 php-xml              x86_64         7.2.24-1.module+el8.4.0+413+c9202dda            appstream         187 k

Transaction Summary
=============================================================================================================
Install  9 Packages
# yum install phpmyadmin

Once you have completed the installation of phpMyAdmin, configure PhpMyAdmin to allow connections from remote hosts by editing the phpmyadmin.conf file, located in the Apache conf.d directory in /etc/httpd/conf.d/phpMyAdmin.conf, and commenting the following lines:

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

Most significantly, after making the changes listed below, you must add “Require all granted,” which will enable network access to phpMyAdmin.

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

	Alias /phpMyAdmin /usr/share/phpMyAdmin
    Alias /phpmyadmin /usr/share/phpMyAdmin
    <Directory /usr/share/phpMyAdmin/>
       AddDefaultCharset UTF-8
       Require all granted
       Require local
    </Directory>

    <Directory /usr/share/phpMyAdmin/setup/>
       Require local
    </Directory>

Save the file using :wq!

Then restart the apache service and verifiy the access on browser by URL address http://server_IP/phpmyadmin

# systemctl restart httpd
PhpMyAdmin

Above image show the phpmyadmin default homepage

Setting authentication type for phpMyAdmin:

The authentication option in phpMyAdmin must then be changed. Four different kinds of authentication are provided by phpMyAdmin. (config, cookie, http, and signon).

In accordance with your needs, you can pick whichever one you prefer. The standard version includes cookies.

  • The traditional method of verification $auth_type = 'config' stores the user name and password in config.inc.php.
  • With the aid of cookies, the “cookie” authentication method $auth_type = "cookie" enables you to log in using any valid MySQL user account.
  • You can register in using any valid MySQL user account using "http" authentication.
  • You can log in using pre-configured PHP session data or a provided PHP script when using the “signon” authentication method $auth_type = "signon".

Use below command to edit the file and search for $cfg['Servers'][$i]['auth_type'] = 'cookie';: and change “cookie” to “http” Authentication type

# vi /etc/phpMyAdmin/config.inc.php

Please refer to the image below that shows the authentication type config changed to http.

configure phpMyAdmin

Once changes done as per above image save the config and restart the apache service to access the phpMyAdmin via http

# systemctl restart httpd

You will be required to enter the login credentials for the user account you made earlier in order to access your phpMyAdmin. Since I have only created the MySQL root account and password here; however, in real-time, you will need to create various accounts based on requirements. It is advised to use separate user accounts for various projects.

Verifiy the access on browser by URL address http://server_IP/phpmyadmin

phpmyadmin http login

You will be directed to the PHPMyAdmin login page after completing the basic authentication, where you must input your administrative user login information for MySQL or MariaDB.

The phpMyAdmin interface, which you’ll see after logging in, will look something like this:

PhpMyAdmin page Afer Login

Congratulations! Your phpMyAdmin is now complete, and you can access the MySQL or MariaDB database on your browser.

Visit this page to restrict access of phpMyAdmin:


How to restrict phpmyAdmin access to a specific IP address

==================================================================================
Was this article of use to you? Post your insightful thoughts or recommendations in the comments section if you don’t find this article to be helpful or if you see any outdated information, a problem, or a typo to help this article better.
==================================================================================

Related Posts

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.