Install phpMyAdmin on Rocky Linux 8

0
209

Follow through this tutorial to learn how to install phpMyAdmin on Rocky Linux 8. phpMyAdmin is a free and opensource application written in PHP that facilitates the administration and management of MySQL and MariaDB over the Web.

phpMyAdmin allows administrators to;

  • browse through databases and tables;
  • create, copy, rename, alter and drop databases;
  • create, copy, rename, alter and drop tables;
  • perform table maintenance;
  • add, edit and drop fields;
  • execute any SQL-statement, even multiple queries;
  • create, alter and drop indexes;
  • load text files into tables;
  • create and read dumps of tables or databases;
  • export data to SQL, CSV, XML, Word, Excel, PDF and LaTeX formats;
  • administer multiple servers;
  • manage MySQL users and privileges;
  • check server settings and runtime information with configuration hints;
  • check referential integrity in MyISAM tables;
  • create complex queries using Query-by-example (QBE), automatically
    connecting required tables;
  • create PDF graphics of database layout;
  • search globally in a database or a subset of it;
  • transform stored data into any format using a set of predefined
    functions, such as displaying BLOB-data as image or download-link;
  • manage InnoDB tables and foreign keys;

Install phpMyAdmin on Rocky Linux 8

Prerequisites

Note: In this guide, we are going to install phpMyAdmin v5.1.1, which the current stable release version as of this writing. This version supports PHP 7.1.3 and MySQL 5.5 or newer. Note this while installing your LAMP/LEMP stack. You can check more requirements including the required PHP modules on PHP requirements page.

Update your system packages.

dnf update

Install LEMP/LAMP Stack on Rocky Linux 8 by following the links provided below;

Install LAMP Stack on Rocky Linux 8

Install LEMP Stack on Rocky Linux 8

In this guide, PHP 7.4, MariaDB 10.5 and Nginx are used.

php -v
PHP 7.4.20 (cli) (built: Jun  1 2021 15:41:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.20, Copyright (c), by Zend Technologies
mysql -V
mysql  Ver 15.1 Distrib 10.5.10-MariaDB, for Linux (x86_64) using readline 5.1
systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/nginx.service.d
           └─php-fpm.conf
   Active: active (running) since Sat 2021-06-19 00:13:03 EAT; 8s ago
  Process: 51988 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 51987 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 51985 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 51990 (nginx)
    Tasks: 2 (limit: 11391)
   Memory: 4.0M
   CGroup: /system.slice/nginx.service
           ├─51990 nginx: master process /usr/sbin/nginx
           └─51991 nginx: worker process

Jun 19 00:13:03 localhost.localdomain systemd[1]: Starting The nginx HTTP and reverse proxy server...
Jun 19 00:13:03 localhost.localdomain nginx[51987]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Jun 19 00:13:03 localhost.localdomain nginx[51987]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Jun 19 00:13:03 localhost.localdomain systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
Jun 19 00:13:03 localhost.localdomain systemd[1]: Started The nginx HTTP and reverse proxy server.

Install Required PHP Modules on Rocky Linux 8

If not already installed, run the command below to install other required PHP extensions for phpMyAdmin.

dnf install php-{spl,hash,ctype,json,mbstring,zip,gd,curl,xml,common}

Install phpMyAdmin on Rocky Linux 8

Once you have setup your LAMP/LEMP stack, databases, your WordPress or whatever your web application is, proceed to install phpMyAdmin.

As of this writing, phpMyAdmin is not available on the default Rocky Linux 8 repos.

dnf whatprovides phpmyadmin
Error: No Matches found

Download phpMyAdmin

Therefore, to install phpMyAdmin on Rocky Linux 8, download the latest source tarball from phpMyAdmin downloads page.

You can download phpMyAdmin kits for English or All languages. This guide is using phpMyAdmin English version only. Make the download easy by using wget command.

To download the latest stable release version, check the versions on the downloads page and simply create a variable to hold the latest version number.

VER=5.1.1
wget https://files.phpmyadmin.net/phpMyAdmin/$VER/phpMyAdmin-$VER-english.tar.gz

Well, you can as well download phpMyAdmin that supports all the languages to enable you run a version of phpMyAdmin with language of your preference;

https://files.phpmyadmin.net/phpMyAdmin/$VER/phpMyAdmin-$VER-all-languages.tar.gz

Verify phpMyAdmin Tarball Integrity

To ensure that you are installing a genuine version of phpMyAdmin, you need to verify the integrity of the downloaded archive.

Download and import phpMyAdmin PGP fingerprint key from the key servers.

gpg --keyserver hkp://pgp.mit.edu --recv-keys 3D06A59ECE730EB71B511C17CE752F178259BD92

Download the PGP signature for your specific version of phpMyAdmin from phpMyAdmin downloads page.

wget https://files.phpmyadmin.net/phpMyAdmin/$VER/phpMyAdmin-$VER-english.tar.gz.asc

Run the signature verification.

gpg --verify phpMyAdmin-$VER-english.tar.gz.asc

Keyword in the output; Good signature.

gpg: assuming signed data in 'phpMyAdmin-5.1.1-english.tar.gz'
gpg: Signature made Fri 04 Jun 2021 07:26:25 AM EAT
gpg:                using RSA key 3D06A59ECE730EB71B511C17CE752F178259BD92
gpg: Good signature from "Isaac Bennetch " [unknown]
gpg:                 aka "Isaac Bennetch " [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 3D06 A59E CE73 0EB7 1B51  1C17 CE75 2F17 8259 BD92

You can as well verify the checksum of the downloaded archive. Download the SHA256 hash for phpMyAdmin-$VER-english.tar.gz.

wget https://files.phpmyadmin.net/phpMyAdmin/$VER/phpMyAdmin-$VER-english.tar.gz.sha256

Calculate the SHA256 hash for downloaded file.

sha256sum phpMyAdmin-$VER-english.tar.gz
f01e0095661dbc45f6f136e35efe55823f8a9715a25afce71fa94f3bb93bcc29  phpMyAdmin-5.1.1-english.tar.gz

Compare the calculated hash with the downloaded hash.

cat phpMyAdmin-$VER-english.tar.gz.sha256
f01e0095661dbc45f6f136e35efe55823f8a9715a25afce71fa94f3bb93bcc29  phpMyAdmin-5.1.1-english.tar.gz

If all is well, you are good to proceed.

Install phpMyAdmin on Rocky Linux 8

Since phpMyAdmin comes as a standalone application ready for installation, simply extract it to your Web root directory. In this guide, we are using Nginx as the web server.

Extract phpMyAdmin Tarball

Create your phpMyAdmin web root directory.

Note that we are using Nginx web server in this setup. Replace the document root folder as per your web server type.

You can choose to use a different directory instead of the one created below;

mkdir /usr/share/nginx/phpmyadmin

Next, extract the phpMyAdmin to the directory created above.

tar xzf phpMyAdmin-$VER-english.tar.gz -C /usr/share/nginx/phpmyadmin --strip-components=1

Create phpMyAdmin Nginx Server Block

You can now create a basic Nginx Server block for phpMyAdmin as shown below. Be sure to replace the directories accordingly.

cat > /etc/nginx/conf.d/phpmyadmin.conf << 'EOL'
server {
    listen       80;
    server_name  pma.kifarunix-demo.com;
    root         /usr/share/nginx/phpmyadmin;
    
    access_log /var/log/nginx/pma.kifarunix-demo.com_access.log;
    error_log /var/log/nginx/pma.kifarunix-demo.com_error.log;

    index   index.php;

    location / {
        try_files    $uri $uri/ /index.php?$args;
    }
    location ~ \.php$ {
         try_files $uri =404;
         fastcgi_intercept_errors on;
         include        fastcgi_params;
         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
         fastcgi_pass unix:/run/php-fpm/www.sock;
     }
}
EOL

Save the configuration file and run Nginx syntax verification.

nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Restart Nginx

systemctl restart nginx

Configure phpMyAdmin

Rename the sample phpMyAdmin configuration file;

cp /usr/share/nginx/phpmyadmin/config{.sample,}.inc.php

Create a blowfish secret required for cookie based authentication to encrypt password in cookie. You can generate the blowfish secret online and paste as follows;

vi /usr/share/nginx/phpmyadmin/config.inc.php
/** $cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
$cfg['blowfish_secret'] = '{yqiCcF/-1G8WE9LE,dD{3mQDBnv[]bN';

Restart Nginx and PHP-FPM for the changes to take effect.

systemctl restart nginx php-fpm

Accessing phpMyAdmin

You can now access your phpMyAdmin from the browser by navigating to browser and using the the address, http://server-host-name.

Install phpMyAdmin on Rocky Linux 8

Login as database administrative user.

If you get the error:

mysqli::real_connect(): (HY000/1698): Access denied for user 'root'@'localhost'

It is because, you havent enabled MySQL Native password authentication. See how to on the link below;

Set Native Password Authentication Method as Default on MariaDB/MySQL

Upon successful authentication, you will land on the phpMyAdmin dashboard.

Install phpMyAdmin on Rocky Linux 8

There you go. You have successfully setup phpMyAdmin. You can now proceed to manage your databases using phpMyAdmin.

That marks the end of our guide on how to install phpMyAdmin on Rocky Linux 8.

Read more on phpMyAdmin user guide.

Other Tutorials

Install phpMyAdmin on Ubuntu 20.04

Install latest phpMyAdmin on CentOS 8

Install phpMyAdmin with Nginx on Debian 10 Buster

LEAVE A REPLY

Please enter your comment!
Please enter your name here