Home Linux guides How to install phpMyAdmin on Rocky Linux 8

How to install phpMyAdmin on Rocky Linux 8

124
0

phpMyAdmin is open-source free software written in PHP for MySQL and MariaDB database server administration over the web. phpMyAdmin can be used to run most administration tasks such as creating a database, running queries, adding user accounts, and so on.

Features of phpMyAdmin.

phpMyAdmin has the following features.

  • create, browse, edit, and drop databases, tables, views, columns, and indexes.
  • load text files into tables
  • create, copy, drop, rename and alter databases, tables, columns and indexes.
  • Creating graphics of your database layout in various formats.
  • Creating complex queries using Query-by-example (QBE)
  • execute, edit and bookmark  SQL-statements.
  • add, edit, and remove MySQL user accounts and privileges.
  • track changes on databases, tables and views

For a full list of features, see https://docs.phpmyadmin.net/ .

Prerequisites.

Before you install phpMyAdmin in your Rocky Linux 8, ensure that the following requirements are met.

  • Web-server e.g Apache, Nginx to install phpMyAdmin files into.
  • PHP 7.1.3 or newer.
  • MySQL-compatible databases e.g MYSQL or MariaDB.
  • A Web browser with cookies and javascript enabled.

Let’s now learn how to Install phpMyAdmin on Rocky Linux 8.

Step 1 : Update Rocky Linux 8

Before we install the web and database server, update your system.

sudo dnf -y update 
sudo dnf -y upgrade
reboot

Step 2 : Install Web-Server.

For the sake of this article, I will work with the Apache HTTP server. The latest release is Apache httpd 2.4.51

To install Apache HTTP server:

sudo dnf install httpd -y

This command will install the Apache HTTP server and all its dependencies.

Command output looks like this.

$ sudo dnf install httpd -y
[sudo] password for Jil: 
Last metadata expiration check: 0:16:28 ago on Thu 07 Oct 2021 09:02:09 PM CEST.
Dependencies resolved.
=============================================================================================
 Package              Arch      Version                                   Repository    Size
=============================================================================================
Installing:
 httpd                x86_64    2.4.37-39.module+el8.4.0+571+fd70afb1     appstream    1.4 M
Installing dependencies:
 apr                  x86_64    1.6.3-11.el8.1                            appstream    124 k
 apr-util             x86_64    1.6.1-6.el8.1                             appstream    104 k
 httpd-filesystem     noarch    2.4.37-39.module+el8.4.0+571+fd70afb1     appstream     37 k
 httpd-tools          x86_64    2.4.37-39.module+el8.4.0+571+fd70afb1     appstream    105 k
 mod_http2            x86_64    1.15.7-3.module+el8.4.0+553+7a69454b      appstream    153 k
 rocky-logos-httpd    noarch    84.5-8.el8                                baseos        22 k
Installing weak dependencies:
 apr-util-bdb         x86_64    1.6.1-6.el8.1                             appstream     23 k
 apr-util-openssl     x86_64    1.6.1-6.el8.1                             appstream     26 k
Enabling module streams:
 httpd                          2.4                                                         

Transaction Summary
=============================================================================================
Install  9 Packages

Total download size: 2.0 M
Installed size: 5.4 M
Downloading Packages:
(1/9): apr-util-bdb-1.6.1-6.el8.1.x86_64.rpm                 424 kB/s |  23 kB     00:00    
(2/9): apr-1.6.3-11.el8.1.x86_64.rpm                         2.0 MB/s | 124 kB     00:00    
(3/9): apr-util-1.6.1-6.el8.1.x86_64.rpm                     1.6 MB/s | 104 kB     00:00    
(4/9): apr-util-openssl-1.6.1-6.el8.1.x86_64.rpm             948 kB/s |  26 kB     00:00    
(5/9): httpd-filesystem-2.4.37-39.module+el8.4.0+571+fd70afb 1.5 MB/s |  37 kB     00:00    
(6/9): httpd-tools-2.4.37-39.module+el8.4.0+571+fd70afb1.x86 6.6 MB/s | 105 kB     00:00    
(7/9): httpd-2.4.37-39.module+el8.4.0+571+fd70afb1.x86_64.rp  32 MB/s | 1.4 MB     00:00    
(8/9): mod_http2-1.15.7-3.module+el8.4.0+553+7a69454b.x86_64 6.7 MB/s | 153 kB     00:00    
(9/9): rocky-logos-httpd-84.5-8.el8.noarch.rpm               503 kB/s |  22 kB     00:00    
---------------------------------------------------------------------------------------------
Total                                                        4.3 MB/s | 2.0 MB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                     1/1 
  Installing       : apr-1.6.3-11.el8.1.x86_64                                           1/9 
  Running scriptlet: apr-1.6.3-11.el8.1.x86_64                                           1/9 
  Installing       : apr-util-bdb-1.6.1-6.el8.1.x86_64                                   2/9 
  Installing       : apr-util-openssl-1.6.1-6.el8.1.x86_64                               3/9 
  Installing       : apr-util-1.6.1-6.el8.1.x86_64                                       4/9 
  Running scriptlet: apr-util-1.6.1-6.el8.1.x86_64                                       4/9 
  Installing       : httpd-tools-2.4.37-39.module+el8.4.0+571+fd70afb1.x86_64            5/9 
  Installing       : rocky-logos-httpd-84.5-8.el8.noarch                                 6/9 
  Running scriptlet: httpd-filesystem-2.4.37-39.module+el8.4.0+571+fd70afb1.noarch       7/9 
  Installing       : httpd-filesystem-2.4.37-39.module+el8.4.0+571+fd70afb1.noarch       7/9 
  Installing       : mod_http2-1.15.7-3.module+el8.4.0+553+7a69454b.x86_64               8/9 
  Installing       : httpd-2.4.37-39.module+el8.4.0+571+fd70afb1.x86_64                  9/9 
  Running scriptlet: httpd-2.4.37-39.module+el8.4.0+571+fd70afb1.x86_64                  9/9 
  Verifying        : apr-1.6.3-11.el8.1.x86_64                                           1/9 
  Verifying        : apr-util-1.6.1-6.el8.1.x86_64                                       2/9 
  Verifying        : apr-util-bdb-1.6.1-6.el8.1.x86_64                                   3/9 
  Verifying        : apr-util-openssl-1.6.1-6.el8.1.x86_64                               4/9 
  Verifying        : httpd-2.4.37-39.module+el8.4.0+571+fd70afb1.x86_64                  5/9 
  Verifying        : httpd-filesystem-2.4.37-39.module+el8.4.0+571+fd70afb1.noarch       6/9 
  Verifying        : httpd-tools-2.4.37-39.module+el8.4.0+571+fd70afb1.x86_64            7/9 
  Verifying        : mod_http2-1.15.7-3.module+el8.4.0+553+7a69454b.x86_64               8/9 
  Verifying        : rocky-logos-httpd-84.5-8.el8.noarch                                 9/9 
Installed products updated.

Installed:
  apr-1.6.3-11.el8.1.x86_64                                                                  
  apr-util-1.6.1-6.el8.1.x86_64                                                              
  apr-util-bdb-1.6.1-6.el8.1.x86_64                                                          
  apr-util-openssl-1.6.1-6.el8.1.x86_64                                                      
  httpd-2.4.37-39.module+el8.4.0+571+fd70afb1.x86_64                                         
  httpd-filesystem-2.4.37-39.module+el8.4.0+571+fd70afb1.noarch                              
  httpd-tools-2.4.37-39.module+el8.4.0+571+fd70afb1.x86_64                                   
  mod_http2-1.15.7-3.module+el8.4.0+553+7a69454b.x86_64                                      
  rocky-logos-httpd-84.5-8.el8.noarch                                                        

Complete!

To Inspect the version installed :

sudo httpd -v

Command output

$ sudo httpd -v
Server version: Apache/2.4.37 (rocky)
Server built:   Jun 11 2021 15:35:05

Congratulations, you have installed the Apache HTTP server in your system.

Step 3 : Start and enable webserver.

We enable the webserver to make sure it’s available on boot time.

To start and enable webserver:

sudo systemctl start httpd
sudo systemctl enable httpd

You can as well check the status of the Apache webserver:

sudo systemctl status httpd

The output of the command.

● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2021-10-07 21:45:18 CEST; 27s ago
     Docs: man:httpd.service(8)
 Main PID: 24716 (httpd)
   Status: "Running, listening on: port 80"
    Tasks: 213 (limit: 49349)
   Memory: 42.7M
   CGroup: /system.slice/httpd.service
           ├─24716 /usr/sbin/httpd -DFOREGROUND
           ├─24727 /usr/sbin/httpd -DFOREGROUND
           ├─24728 /usr/sbin/httpd -DFOREGROUND
           ├─24729 /usr/sbin/httpd -DFOREGROUND
           └─24730 /usr/sbin/httpd -DFOREGROUND

Oct 07 21:45:18 rocky-linux-01.localdomain systemd[1]: Starting The Apache HTTP Server...
Oct 07 21:45:18 rocky-linux-01.localdomain systemd[1]: Started The Apache HTTP Server.
Oct 07 21:45:18 rocky-linux-01.localdomain httpd[24716]: Server configured, listening on: port 80

Our server is loaded and running.

Step 4 : Allow HTTP services through firewall.

Execute this command.

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload

Step 5 : Install MySQL Database.

To install MySQL database in your system:

sudo dnf install mysql-server mysql -y

The output of the command:

$ sudo dnf install mysql-server mysql -y
Last metadata expiration check: 0:56:12 ago on Thu 07 Oct 2021 09:02:09 PM CEST.
Dependencies resolved.
=============================================================================================
 Package                     Arch    Version                                Repository  Size
=============================================================================================
Installing:
 mysql                       x86_64  8.0.26-1.module+el8.4.0+652+6de068a7   appstream   12 M
 mysql-server                x86_64  8.0.26-1.module+el8.4.0+652+6de068a7   appstream   25 M
Installing dependencies:
 mariadb-connector-c-config  noarch  3.1.11-2.el8_3                         appstream   14 k
 mecab                       x86_64  0.996-1.module+el8.3.0+242+87d3366a.9  appstream  392 k
 mysql-common                x86_64  8.0.26-1.module+el8.4.0+652+6de068a7   appstream  133 k
 mysql-errmsg                x86_64  8.0.26-1.module+el8.4.0+652+6de068a7   appstream  597 k
 protobuf-lite               x86_64  3.5.0-13.el8                           appstream  148 k
Enabling module streams:
 mysql                               8.0                                                    

Transaction Summary
=============================================================================================
Install  7 Packages

Total download size: 38 M
Installed size: 195 M
Downloading Packages:
(1/7): mariadb-connector-c-config-3.1.11-2.el8_3.noarch.rpm  321 kB/s |  14 kB     00:00    
(2/7): mysql-common-8.0.26-1.module+el8.4.0+652+6de068a7.x86 3.7 MB/s | 133 kB     00:00    
(3/7): mysql-errmsg-8.0.26-1.module+el8.4.0+652+6de068a7.x86 9.1 MB/s | 597 kB     00:00    
(4/7): mecab-0.996-1.module+el8.3.0+242+87d3366a.9.x86_64.rp 2.4 MB/s | 392 kB     00:00    
(5/7): protobuf-lite-3.5.0-13.el8.x86_64.rpm                 3.1 MB/s | 148 kB     00:00    
(6/7): mysql-8.0.26-1.module+el8.4.0+652+6de068a7.x86_64.rpm  31 MB/s |  12 MB     00:00    
(7/7): mysql-server-8.0.26-1.module+el8.4.0+652+6de068a7.x86  34 MB/s |  25 MB     00:00    
---------------------------------------------------------------------------------------------
Total                                                         37 MB/s |  38 MB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                     1/1 
  Installing       : mariadb-connector-c-config-3.1.11-2.el8_3.noarch                    1/7 
  Installing       : mysql-common-8.0.26-1.module+el8.4.0+652+6de068a7.x86_64            2/7 
  Installing       : mysql-8.0.26-1.module+el8.4.0+652+6de068a7.x86_64                   3/7 
  Installing       : mysql-errmsg-8.0.26-1.module+el8.4.0+652+6de068a7.x86_64            4/7 
  Installing       : protobuf-lite-3.5.0-13.el8.x86_64                                   5/7 
  Installing       : mecab-0.996-1.module+el8.3.0+242+87d3366a.9.x86_64                  6/7 
  Running scriptlet: mecab-0.996-1.module+el8.3.0+242+87d3366a.9.x86_64                  6/7 
  Running scriptlet: mysql-server-8.0.26-1.module+el8.4.0+652+6de068a7.x86_64            7/7 
  Installing       : mysql-server-8.0.26-1.module+el8.4.0+652+6de068a7.x86_64            7/7 
  Running scriptlet: mysql-server-8.0.26-1.module+el8.4.0+652+6de068a7.x86_64            7/7 
ValueError: File context for /var/log/mysql(/.*)? already defined

  Verifying        : mariadb-connector-c-config-3.1.11-2.el8_3.noarch                    1/7 
  Verifying        : mecab-0.996-1.module+el8.3.0+242+87d3366a.9.x86_64                  2/7 
  Verifying        : mysql-8.0.26-1.module+el8.4.0+652+6de068a7.x86_64                   3/7 
  Verifying        : mysql-common-8.0.26-1.module+el8.4.0+652+6de068a7.x86_64            4/7 
  Verifying        : mysql-errmsg-8.0.26-1.module+el8.4.0+652+6de068a7.x86_64            5/7 
  Verifying        : mysql-server-8.0.26-1.module+el8.4.0+652+6de068a7.x86_64            6/7 
  Verifying        : protobuf-lite-3.5.0-13.el8.x86_64                                   7/7 
Installed products updated.

Installed:
  mariadb-connector-c-config-3.1.11-2.el8_3.noarch                                           
  mecab-0.996-1.module+el8.3.0+242+87d3366a.9.x86_64                                         
  mysql-8.0.26-1.module+el8.4.0+652+6de068a7.x86_64                                          
  mysql-common-8.0.26-1.module+el8.4.0+652+6de068a7.x86_64                                   
  mysql-errmsg-8.0.26-1.module+el8.4.0+652+6de068a7.x86_64                                   
  mysql-server-8.0.26-1.module+el8.4.0+652+6de068a7.x86_64                                   
  protobuf-lite-3.5.0-13.el8.x86_64                                                          

Complete!

From the output, the MYSQL server and its dependencies are successfully installed.

Step 6 : Start and enable MySQL

To Start and enable MySQL in your system:

sudo systemctl start mysqld
sudo systemctl enable mysqld
sudo systemctl status mysqld

The output of the status command:

 sudo systemctl status mysqld
● mysqld.service - MySQL 8.0 database server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2021-10-07 22:03:18 CEST; 34s ago
 Main PID: 26010 (mysqld)
   Status: "Server is operational"
    Tasks: 38 (limit: 49349)
   Memory: 464.0M
   CGroup: /system.slice/mysqld.service
           └─26010 /usr/libexec/mysqld --basedir=/usr

Oct 07 22:03:14 rocky-linux-01.localdomain systemd[1]: Starting MySQL 8.0 database server...
Oct 07 22:03:14 rocky-linux-01.localdomain mysql-prepare-db-dir[25926]: Initializing MySQL d>
Oct 07 22:03:18 rocky-linux-01.localdomain systemd[1]: Started MySQL 8.0 database server.

From the output, my database server is loaded and active. You have successfully installed MySQL server in your system.

Step 7 : Secure your Database:

To secure your database with a Strong password, issue the command below and follow the prompts.

sudo mysql_secure_installation

The output of the command is as shown:

sudo mysql_secure_installation
[sudo] password for Jil: 

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Please set the password for root here.

New password: 

Re-enter new password: 

Estimated strength of the password: 50 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
 ... Failed! Error: Your password does not satisfy the current policy requirements

New password: 

Re-enter new password: 

Estimated strength of the password: 50 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
 ... Failed! Error: Your password does not satisfy the current policy requirements

New password: 

Re-enter new password: 

Estimated strength of the password: 100 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done! 

PHP Installation.

We now turn our focus to PHP installation.

Step 1 : Reset php module.

To reset the current PHP module in your system, issue the command :

sudo dnf module reset php

Step 2 : Enable PHP 7.4

In this article, I will enable PHP version 7.4 which is the current stable release.

Run the command :

sudo dnf module enable php:7.4

Command output :

sudo dnf module enable php:7.4
Last metadata expiration check: 1:26:52 ago on Thu 07 Oct 2021 09:02:09 PM CEST.
Dependencies resolved.
=============================================================================================
 Package              Architecture        Version                 Repository            Size
=============================================================================================
Enabling module streams:
 php                                      7.4                                               

Transaction Summary
=============================================================================================
Is this ok [y/N]: y
Complete!

Step 3 : Install PHP and modules required for phpMyAdmin

To install PHP and its various modules that are required for phpMyAdmin, issue the command below:

sudo dnf install php php-common php-opcache php-cli php-gd php-curl php-mysqlnd php-xml -y

The output of the command is shown:

sudo dnf install php php-common php-opcache php-cli php-gd php-curl php-mysqlnd php-xml -y
[sudo] password for Jil: 
Last metadata expiration check: 1:35:22 ago on Thu 07 Oct 2021 09:02:09 PM CEST.
Dependencies resolved.
=============================================================================================
 Package             Arch      Version                                    Repository    Size
=============================================================================================
Installing:
 php                 x86_64    7.4.6-4.module+el8.4.0+415+e936cba3        appstream    1.5 M
 php-cli             x86_64    7.4.6-4.module+el8.4.0+415+e936cba3        appstream    3.1 M
 php-common          x86_64    7.4.6-4.module+el8.4.0+415+e936cba3        appstream    694 k
 php-gd              x86_64    7.4.6-4.module+el8.4.0+415+e936cba3        appstream     84 k
 php-mysqlnd         x86_64    7.4.6-4.module+el8.4.0+415+e936cba3        appstream    191 k
 php-opcache         x86_64    7.4.6-4.module+el8.4.0+415+e936cba3        appstream    265 k
 php-xml             x86_64    7.4.6-4.module+el8.4.0+415+e936cba3        appstream    173 k
Installing dependencies:
 nginx-filesystem    noarch    1:1.14.1-9.module+el8.4.0+542+81547229     appstream     23 k
 php-pdo             x86_64    7.4.6-4.module+el8.4.0+415+e936cba3        appstream    122 k
Installing weak dependencies:
 php-fpm             x86_64    7.4.6-4.module+el8.4.0+415+e936cba3        appstream    1.6 M
 php-json            x86_64    7.4.6-4.module+el8.4.0+415+e936cba3        appstream     73 k
 php-mbstring        x86_64    7.4.6-4.module+el8.4.0+415+e936cba3        appstream    482 k

Transaction Summary
=============================================================================================
Install  12 Packages

Total download size: 8.2 M
Installed size: 32 M
Downloading Packages:
(1/12): nginx-filesystem-1.14.1-9.module+el8.4.0+542+8154722 518 kB/s |  23 kB     00:00    
(2/12): php-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64.rpm    14 MB/s | 1.5 MB     00:00    
(3/12): php-common-7.4.6-4.module+el8.4.0+415+e936cba3.x86_6  10 MB/s | 694 kB     00:00    
(4/12): php-gd-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64.rp 5.6 MB/s |  84 kB     00:00    
(5/12): php-json-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64. 7.7 MB/s |  73 kB     00:00    
(6/12): php-cli-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64.r  20 MB/s | 3.1 MB     00:00    
(7/12): php-mysqlnd-7.4.6-4.module+el8.4.0+415+e936cba3.x86_  17 MB/s | 191 kB     00:00    
(8/12): php-fpm-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64.r  24 MB/s | 1.6 MB     00:00    
(9/12): php-opcache-7.4.6-4.module+el8.4.0+415+e936cba3.x86_  18 MB/s | 265 kB     00:00    
(10/12): php-pdo-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64.  15 MB/s | 122 kB     00:00    
(11/12): php-xml-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64.  10 MB/s | 173 kB     00:00    
(12/12): php-mbstring-7.4.6-4.module+el8.4.0+415+e936cba3.x8 1.6 MB/s | 482 kB     00:00    
---------------------------------------------------------------------------------------------
Total                                                         14 MB/s | 8.2 MB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                     1/1 
  Installing       : php-common-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64              1/12 
  Installing       : php-pdo-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                 2/12 
  Installing       : php-cli-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                 3/12 
  Installing       : php-json-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                4/12 
  Installing       : php-mbstring-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64            5/12 
  Installing       : php-opcache-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64             6/12 
  Installing       : php-xml-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                 7/12 
  Running scriptlet: nginx-filesystem-1:1.14.1-9.module+el8.4.0+542+81547229.noarch     8/12 
  Installing       : nginx-filesystem-1:1.14.1-9.module+el8.4.0+542+81547229.noarch     8/12 
  Installing       : php-fpm-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                 9/12 
  Running scriptlet: php-fpm-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                 9/12 
  Installing       : php-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                    10/12 
  Installing       : php-mysqlnd-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64            11/12 
  Installing       : php-gd-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                 12/12 
  Running scriptlet: php-gd-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                 12/12 
  Running scriptlet: php-fpm-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                12/12 
  Verifying        : nginx-filesystem-1:1.14.1-9.module+el8.4.0+542+81547229.noarch     1/12 
  Verifying        : php-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                     2/12 
  Verifying        : php-cli-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                 3/12 
  Verifying        : php-common-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64              4/12 
  Verifying        : php-fpm-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                 5/12 
  Verifying        : php-gd-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                  6/12 
  Verifying        : php-json-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                7/12 
  Verifying        : php-mbstring-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64            8/12 
  Verifying        : php-mysqlnd-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64             9/12 
  Verifying        : php-opcache-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64            10/12 
  Verifying        : php-pdo-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                11/12 
  Verifying        : php-xml-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                12/12 
Installed products updated.

Installed:
  nginx-filesystem-1:1.14.1-9.module+el8.4.0+542+81547229.noarch                             
  php-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                                             
  php-cli-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                                         
  php-common-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                                      
  php-fpm-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                                         
  php-gd-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                                          
  php-json-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                                        
  php-mbstring-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                                    
  php-mysqlnd-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                                     
  php-opcache-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                                     
  php-pdo-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                                         
  php-xml-7.4.6-4.module+el8.4.0+415+e936cba3.x86_64                                         

Complete!

From the output, our modules and their dependencies are successfully installed.

Step 4 : Download and unpack phpMyAdmin.

To download the latest phpMyAdmin package, visit the official phpMyAdmin downloads page https://www.phpmyadmin.net/downloads/

Copy the link address to your download file and using the command wget, download your package.

wget https://files.phpmyadmin.net/phpMyAdmin/5.1.1/phpMyAdmin-5.1.1-all-languages.zip

Your command will execute as shown below:

wget https://files.phpmyadmin.net/phpMyAdmin/5.1.1/phpMyAdmin-5.1.1-all-languages.zip
--2021-10-07 22:49:57--  https://files.phpmyadmin.net/phpMyAdmin/5.1.1/phpMyAdmin-5.1.1-all-languages.zip
Connecting to 192.168.201.2:3128... connected.
Proxy request sent, awaiting response... 200 OK
Length: 14801905 (14M) [application/zip]
Saving to: ‘phpMyAdmin-5.1.1-all-languages.zip’

phpMyAdmin-5.1.1-all-la 100%[============================>]  14.12M  88.8MB/s    in 0.2s    

2021-10-07 22:49:57 (88.8 MB/s) - ‘phpMyAdmin-5.1.1-all-languages.zip’ saved [14801905/14801905]

Step 5 : Unzip your file.

This is achieved by using the unzip command.

unzip phpMyAdmin-5.1.1-all-languages.zip 

Step 6 : Move file to new directory

Move your file to a different directory and rename it.

sudo mv phpMyAdmin-5.1.1-all-languages /usr/share/phpmyadmin

That is awesome, hope you are still following, we will now configure our phpMyAdmin.

Configure phpMyAdmin.

To configure phpMyAdmin:

Step 1 : Change Directory to /usr/share/phpmyadmin

cd /usr/share/phpmyadmin

Then copy the sample configuration file

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

After this, generate a 32-bit secret string

sudo openssl rand -base64 32

The output of the command :

sudo openssl rand -base64 32
VNBICJy+LBjLWp2JPOeYF23DgzKA9rx8XDzWMKhzb/E=

Copy this long code and using the text editor of your choice, edit the config file created above.

sudo vi config.inc.php

Once you are in the config file, scroll down to this section:

/**
 * This is needed for cookie based authentication to encrypt password in
 * cookie. Needs to be 32 chars long.
 */
$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

Paste your code generated by OpenSSL rand -base64 32 between the two single quotes $cfg[‘blowfish_secret’] = ‘PASTE YOUR CODE HERE’;

As shown below:


/**
 * This is needed for cookie based authentication to encrypt password in
 * cookie. Needs to be 32 chars long.
 */
$cfg['blowfish_secret'] = 'VNBICJy+LBjLWp2JPOeYF23DgzKA9rx8XDzWMKhzb/E='; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

Next, scroll down to the section Directories for saving/loading files from server and add this code $cfg[‘TempDir’] = ‘/tmp’;

/**
 * Directories for saving/loading files from server
 */
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
$cfg['TempDir'] = '/tmp';

After these changes save and close your text editor

Next, create a new tmp directory and give it all permissions.

run the commands below:

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

Create Apache Config file.

To create Apache config file, use the text editor of your choice and issue this command :

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

Then paste this 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>
</Directory>

<Directory /usr/share/phpmyadmin/setup/>
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require all granted
</RequireAny>
</IfModule>
</Directory>

Save and exit your editor.

Set SELinux policies

For SELinux to allow traffic to location /usr/share/phpmyadmin:

Issue the command :

sudo chcon -Rv --type=httpd_sys_content_t /usr/share/phpmyadmin/*

Then restart Apache.

sudo systemctl restart httpd

To Access phpMyAdmin web interface

To access phpMyAdmin, go to your web browser and point it to http://SERVER/phpmyadmin. The SERVER is your hosting server IP address. If your installation went on well, you should be prompted to enter the login credentials.

As per the screenshot below.

phpMyAdmin-configuration-screenshot

Conclusion.

Congratulations, you have installed and configured phpMyAdmin on Rocky Linux 8. I would like to hear from you if at all you have encountered any problem with the outlined steps above. please feel free to leave a comment.

LEAVE A REPLY

Please enter your comment!
Please enter your name here