centos8

------

Install and Configure phpMyAdmin on RHEL / CentOS 8

Step 1: Install PHP

phpMyAdmin is written in PHP and you’ll need it installed on your RHEL server. We had written a comprehensive guide on installation of PHP on RHEL 8.

How to Install PHP on RHEL 8 / CentOS 8

Ensure php-mysqlnd extension is installed.

sudo yum -y install php-mysqlnd

Step 2: Install MariaDB/MySQL Database Server

The next step is to install the MariaDB/MySQL database server. Follow guides below to install MariaDB or MySQL on RHEL 8.

How to Install MySQL 8.0 on RHEL 8

How to Install MariaDB Database Server on RHEL 8

Step 3: Install Apache Web Server

phpMyAdmin support both Apache and Nginx as web server. We chose Apache httpd server because it is the most used Web server in enterprise and RHEL ecosystem.

Use our guide below to install Apache web server on RHEL 8.

How to Install Apache with mod_ssl & mod_http2 on RHEL 8

Step 4: Install phpMyAdmin on RHEL 8

Visit phpMyAdmin downloads page and check the latest available package. As of this writing, this is version 4.9.0.1.

Save version to variable.

export VER="4.9.0.1"

The download the latest release as specified above.

curl -o phpMyAdmin-${VER}-all-languages.tar.gz https://files.phpmyadmin.net/phpMyAdmin/${VER}/phpMyAdmin-${VER}-all-languages.tar.gz

For English language only package, use:

curl -o phpMyAdmin-${VER}-english.tar.gz  https://files.phpmyadmin.net/phpMyAdmin/${VER}/phpMyAdmin-${VER}-english.tar.gz

Extract downloaded Archive

$ tar xvf phpMyAdmin-${VER}-english.tar.gz

OR

$ tar xvf phpMyAdmin-${VER}-all-languages.tar.gz

Move the folder to /usr/share/phpmyadmin.

rm phpMyAdmin-*.tar.gz

sudo mv phpMyAdmin-* /usr/share/phpmyadmin

Create directory for phpMyAdmin temp files.

sudo mkdir -p /var/lib/phpmyadmin/tmp

sudo chown -R apache:apache /var/lib/phpmyadmin

Create directory for phpMyAdmin configuration files such as htpass file.

sudo mkdir /etc/phpmyadmin/

Create phpMyAdmin configuration file.

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

Edit the file

sudo vim /usr/share/phpmyadmin/config.inc.php

Set a secret passphrase – Needs to be 32 chars long

$cfg['blowfish_secret'] = 'H2OxcGXxflSd8JwrwVlh6KW6s2rER63i';

Configure Temp directory

$cfg['TempDir'] = '/var/lib/phpmyadmin/tmp';

Step 5: Configure Apache web Server

Create phpMyAdmin Apache configuration file.

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

Add below data:

# Apache configuration for phpMyAdmin Alias /phpMyAdmin /usr/share/phpmyadmin/ Alias /phpmyadmin /usr/share/phpmyadmin/   <Directory /usr/share/phpmyadmin/>    AddDefaultCharset UTF-8      <IfModule mod_authz_core.c>      # Apache 2.4      Require all granted    </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>

You can restrict access from specific IP by adding line like below

Require ip 127.0.0.1 192.168.0.0/24

Validate Apache configuration.

$ sudo apachectl configtest

Syntax OK

Restart httpd service to load new configuration,

sudo systemctl restart httpd

Step 5: Configure SELinux and Firewall

If you have SELinux in Enforcing mode, you’ll get Permission denied error when you try to access phpMyAdmin page. Allow httpd to serve content in the phpmyadmin directory.

sudo semanage fcontext -a -t httpd_sys_content_t "/usr/share/phpmyadmin(/.*)?"

Apply the policy by running the command.

sudo restorecon -Rv /usr/share/phpmyadmin

Allow http port in the firewall.

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

Reload firewall reload configuration.

sudo firewall-cmd --reload

Step 6: Access phpMyAdmin Web interface on RHEL 8

Open the URL http://[ServerIP|Hostname]/phpmyadmin

Login to phpMyAdmin dashboard with your Database credentials – username & password.

Congratulations!. You have successfully installed phpMyAdmin on RHEL 8. Enjoy administering MySQL/MariaDB database operations from a web dashboard. You can also check:

---------