CentLinux | Learn How to Install CentOS/Rocky Linux Servers

Thursday, April 21, 2022

How to Install phpMyAdmin on Rocky Linux 8

Install phpMyAdmin on Rocky Linux 8

In this article, you will learn how to install phpMyAdmin on Rocky Linux 8 or other RPM based distros.

 

Table of Contents:

 

What is phpMyAdmin? :

phpMyAdmin is a free and open source administration tool for MySQL and MariaDB. As a portable web application written primarily in PHP, it has become one of the most popular MySQL administration tools, especially for web hosting services. (Source: Wikipedia)

Recommended Book: Mastering phpMyAdmin 3.4 for Effective MySQL Management

Install phpMyAdmin on Rocky Linux 8

Features in phpMyAdmin:

Features provided by the phpMyAdmin include:

  • Web interface
  • MySQL and MariaDB database management
  • Import data from CSV, JSON and SQL
  • Export data to various formats: CSV, SQL, XML, JSON, PDF (via the TCPDF library), ISO/IEC 26300 - OpenDocument Text and Spreadsheet, Word, Excel, LaTeX, SQL, and others
  • Administering multiple servers
  • Creating PDF graphics of the database layout
  • Creating complex queries using query-by-example (QBE)
  • Searching globally in a database or a subset of it
  • Transforming stored data into any format using a set of predefined functions, like displaying BLOB-data as image or download-link
  • Live charts to monitor MySQL server activity like connections, processes, CPU/memory usage, etc.
  • Network traffic to the SQL server
  • Working with different operating systems like Windows*, Linux*, OS/2, Free BSD* Unix* (such as Sun* Solaris* , AIX) and others.
  • Make complex SQL queries easier.

 

Environment Specification:

We are using the same Linux virtual machine, where we have installed MariaDB database server in our previous article. Virtual machine specifications are:

  • CPU - 3.4 Ghz (2 cores)
  • Memory - 2 GB
  • Storage - 20 GB
  • Operating System - Rocky Linux 8.5 (Green Obsidian)
  • Hostname – mariadb-01.centlinux.com
  • IP Address - 192.168.116.128 /24

 

Update your Rocky Linux Server:

By using a SSH client software, login to mariadb-01.centlinux.com as root user.

Rebuild cache of installed yum repositories.

# dnf makecache
MariaDB                                         1.5 kB/s | 3.4 kB     00:02
Rocky Linux 8 - AppStream                       434 kB/s | 9.7 MB     00:22
Rocky Linux 8 - BaseOS                          647 kB/s | 6.8 MB     00:10
Rocky Linux 8 - Extras                          3.6 kB/s |  12 kB     00:03
Metadata cache created.

Execute following command to update your Rocky Linux server.

# dnf update -y
Last metadata expiration check: 0:00:59 ago on Thu 14 Apr 2022 10:49:04 PM PKT.
Dependencies resolved.
Nothing to do.
Complete!

Check the Linux Operating System and Kernel versions as follows.

# cat /etc/rocky-release && uname -r
Rocky Linux release 8.5 (Green Obsidian)
4.18.0-348.20.1.el8_5.x86_64

 

Install Apache & PHP on Rocky Linux:

phpMyAdmin is PHP based web application, therefore, you are required to install a PHP supported web server to deploy phpMyAdmin software.

You can install Apache HTTP server on your Linux machine as follows.

# dnf install -y @httpd

You are also required to install PHP support on your web server.

Check the available PHP modules in your enabled yum repositories.

# dnf module list php
Last metadata expiration check: 0:02:04 ago on Thu 14 Apr 2022 10:49:04 PM PKT.
Rocky Linux 8 - AppStream
Name      Stream       Profiles                       Summary
php       7.2 [d]      common [d], devel, minimal     PHP scripting language
php       7.3          common [d], devel, minimal     PHP scripting language
php       7.4          common [d], devel, minimal     PHP scripting language

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

We are installing phpMyAdmin 5.1.3 that requires PHP 7.1.3 or later.

Therefore, you may install PHP 7.4 on your Rocky Linux server.

# dnf module install php:7.4

Install necessary PHP packages in one single dnf statement as follows.

# dnf install -y php-common php-opcache php-cli php-gd php-curl php-mysqlnd php-xml wget policycoreutils-python-utils

Enable and start Apache and PHP services.

# systemctl enable --now httpd.service php-fpm.service
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.

We will use the HTTPS port for better security in this article. Therefore, you have to allow the HTTPS in Linux firewall.

# firewall-cmd --permanent --add-service=https
success
# firewall-cmd --reload
success

 

Install phpMyAdmin 5.1.3 on Rocky Linux:

phpMyAdmin is free and open source software, thus can be downloaded from their official website.

At the time of writing this article, phpMyAdmin 5.1.3 is the stable release available to download. Therefore, copy the URL of the phpMyAdmin software and use wget command to download it straight from Linux command line.

# cd /tmp
# wget https://files.phpmyadmin.net/phpMyAdmin/5.1.3/phpMyAdmin-5.1.3-english.tar.gz
--2022-04-14 23:13:01--  https://files.phpmyadmin.net/phpMyAdmin/5.1.3/phpMyAdmin-5.1.3-english.tar.gz
Resolving files.phpmyadmin.net (files.phpmyadmin.net)... 37.19.218.108, 2a02:6ea0:e100::7
Connecting to files.phpmyadmin.net (files.phpmyadmin.net)|37.19.218.108|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7560234 (7.2M) [application/octet-stream]
Saving to: ‘phpMyAdmin-5.1.3-english.tar.gz’

phpMyAdmin-5.1.3-en 100%[===================>]   7.21M  1.21MB/s    in 6.6s

2022-04-14 23:13:09 (1.09 MB/s) - ‘phpMyAdmin-5.1.3-english.tar.gz’ saved [7560234/7560234]

By using tar command, extract downloaded zip file in Apache's document root directory.

# tar xvf phpMyAdmin-5.1.3-english.tar.gz --directory /var/www/html

Rename the extracted directory to a simple name for easy accessibility.

# cd
# mv /var/www/html/phpMyAdmin-5.1.3-english/ /var/www/html/pma

phpMyAdmin software provides a SQL script to create it's repository in MySQL database.

You can execute this script as follows.

# mysql -u root -p < /var/www/html/pma/sql/create_tables.sql
Enter password:

Create a copy of phpMyAdmin configuration file to customize it according to your requirements.

# cp /var/www/html/pma/config.sample.inc.php /var/www/html/pma/config.inc.php

Open phpMyAdmin configuration file in vim text editor.

# vi /var/www/html/pma/config.inc.php

Find and set following directive in this file.

$cfg['blowfish_secret'] = 'I;Am;Fan;0f;0p3n;S0urc3;S0ftwar3'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

Create a temporary directory to cache templates by phpMyAdmin.

# mkdir /var/www/html/pma/tmp

Set apache user as owner of phpMyAdmin software directory.

# chown -R apache:apache /var/www/html/pma/

Set SELinux permissions for tmp directory, to make it writable by the apache user.

# semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/pma/tmp(/.*)?"
# restorecon -Rv /var/www/html/pma/tmp
Relabeled /var/www/html/pma/tmp from unconfined_u:object_r:httpd_sys_content_t:s0 to unconfined_u:object_r:httpd_sys_rw_content_t:s0

Create an admin user for phpMyAdmin.

# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 25
Server version: 10.8.2-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE USER ahmer@localhost IDENTIFIED BY 'pma';

MariaDB [(none)]> GRANT ALL ON *.* TO ahmer@localhost;

MariaDB [(none)]> FLUSH PRIVILEGES;

Open URL https://mariadb-01.centlinux.com/pma/ in a web browser.

phpmyadmin

Login as MySQL admin user.

phpmyadmin-dashboard

 

Conclusion:

In this article, you have learned how to install phpMyAdmin on Rocky Linux 8 or other RPM based distros.

If you find this article useful? Consider supporting us by Buy Me A Coffee


2 comments:

  1. Good morning! The sql server installation procedure was skipped.

    ReplyDelete
    Replies
    1. MariaDB server installation is performed in our previous article https://www.centlinux.com/2022/04/install-mariadb-database-server-on-rocky-linux.html

      Delete

© 2023 CentLinux. All Rights Reserved.