INFORMATICS

The Best

How to Install phpMyAdmin on CentOS 8

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

How to Install phpMyAdmin on CentOS 8

Step 1 Update your base system with the latest available packages.
# dnf update -y

Step 2 – Install Apache, MariaDB and PHP
Before starting, install Apache, MariaDB, PHP and other required PHP extensions with the following command:
dnf install httpd mariadb-server php php-cli php-json php-mbstring php-pdo php-pecl-zip php-mysqlnd -y

Step 3 – Set MariaDB Root Password

First, start the MariaDB service and enable it to start on boot time with the following command:

systemctl start mariadb
systemctl enable mariadb

Next, set the MySQL root password using the following script:

mysql_secure_installation
This script will set the MySQL root password, remove anonymous users, disallow root login remotely and remove the test database and access to it, as shown below:

Enter current password for root (enter for none):

Set root password? [Y/n] Y
New password:
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

 

Step 4 – Install phpMyAdmin ver. 5.x.x
First, download the latest version of phpMyAdmin to the Apache web root directory using the following command:

# cd /var/www/html
wget https://files.phpmyadmin.net/phpMyAdmin/5.0.2/phpMyAdmin-5.0.2-all-languages.tar.gz
Once downloaded, unzip the downloaded file with the following command:

# tar xvf phpMyAdmin-5.0.2-all-languages.tar.gz
Next, rename the extracted directory to phpmyadmin as shown below:

# mv phpMyAdmin-5.0.2-all-languages phpmyadmin
Next, change the ownership of the phpmyadmin directory to the apache user:

# chown -R apache:apache /var/www/html/phpmyadmin
Next, rename the config.sample.inc.php file:

# cd /var/www/html/phpmyadmin
# mv /usr/share/phpMyAdmin/config.sample.inc.php /usr/share/phpMyAdmin/config.inc.php
Next, edit the file and define your secure password:

# nano /etc/httpd/conf.d/phpmyadmin.conf
Find the line below and update with your secure password, as shown below:

 

Step 5 – Configure Apache for phpMyAdmin
Next, create an Apache virtual host configuration file for phpMyAdmin:

nano /etc/httpd/conf.d/phpmyadmin.conf
Add the following lines:

Alias /phpmyadmin /var/www/html/phpmyadmin

<Directory /var/www/html/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 /var/www/html/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>
Save and close the file. Then, start the Apache service and enable it to start after system reboot with the following command:

systemctl start httpd
systemctl enable httpd
Now, open your web browser and visit the URL http://your-server-address or IP/phpmyadmin. You should see the phpMyAdmin web interface in the following screen:

Search