How Install phpMyAdmin on AlmaLinux 8 (best Method)

In this tutorial, which is a complete and reference tutorial, we will fully discuss how to install phpMyAdmin on AlmaLinux 8.

The phpMyAdmin is a PHP web-applications that can be run under any operating system, including Windows, macOS, Linux, and BSDs. The main components that you must install before installing phpMyAdmin are PHP packages and a web server, you can be Apache, Nginx, etc.

phpMyAdmin is a free and open-source tool that enables you to manage MySQL and MariaDB databases from the web browser. The phpMyAdmin is a fully capable web application written in PHP with the main purpose to handle the administration of MySQL/MariaDB over the web. It provides a robust and user-friendly interface for managing databases, tables, database users, basic crud operations (create, read, update, delete), and so much more.

 

The best method to install phpMyAdmin on AlmaLinux 8 with Apache #

Prerequisites #

Before installing PHPMyAdmin, you need to have the following requisite packages installed.

  • PHP
  • Database Server(MySQL or MariaDB)
  • Apache Webserver

1. Install Apache, PHP, and MySQL #

PhpMyAdmin requires an Apache web server so that we can access it using the browser. As it is written using PHP hence that must be there on the server including MySQL Database.

If you have these three things then move forward otherwise see our tutorial- how to set up a LAMP server on AlmaLinux 8

2. Download phpMyAdmin Source Code #

The file we require to install and set up this GUI MySQL Database management is neither available in the base repo of AlmaLinux and nor in EPEL. Hence, we have to download it manually from its website. Visit the download page, right-click on the latest version and copy the link.

Change the working directory to ‘/var/www’ and download the source code of phpMyAdmin using the wget command as below.

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

3. Extract the zip and configure phpMyAdmin
#

Now extract the phpMyAdmin source code and you will get the new directory name as ‘phpMyAdmin-VERSION-NUMBER‘. Now rename the directory to ‘phpmyadmin‘ as below.

1. Install unzip #

Code
dnf install unzip

2. Extract file #

Code
unzip phpMyAdmin-*-all-languages.zip

3. Move the extracted files #

Code
mv phpMyAdmin-*-all-languages /usr/share/phpmyadmin

4. Create config.inc.php #

The sample configuration file for phpMyAdmin is already there, only need to rename it:

Code
 

cd /usr/share/phpmyadmin

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

5. Generate 32-bit Secret string #

Next, generate random strong and number (secret) using the openssl command below.

Code
openssl rand -base64 32 

Copy the generated secret to your note.

6. Edit Configuration file #

Edit the phpMyAdmin configuration ‘config.inc.php’ using nano editor.

Code
sudo nano config.inc.php 

7. Set the blowfish_secret string and temp directory for phpMyAdmin #

In the configuration go to the following line:

Code
$cfg[‘blowfish_secret’] = ”;

Change the value of “$cfg[‘blowfish_secret’] = ‘…..’;” with your generated secret on top as below.

Code
$cfg[‘blowfish_secret’] = ‘yourgeneratedstring’;

phpMyAdmin configuration
phpMyAdmin configuration

Next, scroll down to the “* Directories for saving/loading files from server” area in the same configuration file and add the following line:

Code
$cfg[‘TempDir’] = ‘/tmp’;

Now press ‘Ctrl+x‘, type ‘y‘, and press ‘Enter‘ to save the configuration and exit.

8. Create a Temporary directory and assign its permission #

Code

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

4.1 Create Apache configuration file for phpMyAdmin (less secure)
#

For this stage, you will be creating a new Apache/httpd configuration for phpMyAdmin. Also, you will be configuring the Apache basic authentication for additional security for phpMyAdmin.

Code
nano /etc/httpd/conf.d/phpmyadmin.conf

Copy-paste the below-given code in it:

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>

And Save the file by pressing Ctrl+X, to confirm press Y and hit the Enter key.

Now , restart Apache to load new configuration.

Code
systemctl restart httpd.service

4.2 Create Apache configuration file for phpMyAdmin (secure) #

If you need more security to access Phpmyadmin follow this stage:

Code
nano /etc/httpd/conf.d/phpmyadmin.conf

Copy-paste the below-given code in it:

Code
# Alias for accessing phpmyadmin
Alias /phpmyadmin /var/www/phpmyadmin

# document root phpmyadmin
<Directory /var/www/phpmyadmin>

# Enable Basic authentication 
    AuthType Basic
    AuthName "Please Enter Your Password"
    AuthUserFile /var/www/phpmyadmin/.htpasswd
    Require valid-user

#    If you're paranoid - use this and allow a specific IP address
#    Order deny,allow
#    Deny from all
#    Allow from 127.0.0.1
#    Allow from ::1

</Directory>

Press ‘Ctrl+x‘, type ‘y‘, then press ‘Enter‘ to save and exit.

Run the following command to create a new apache basic authentication password. Change the user ‘mahdi‘ with your username.

Code
htpasswd -c /usr/share/phpmyadmin/.htpasswd mahdi

Type the password for your user and repeat.

Next, change the working directory to ‘/usr/share/phpmyadmin‘ and create a new configuration ‘.htaccess’ using nano editor

Code

cd /usr/share/phpmyadmin
nano .htaccess

Copy and paste the following configuration.

Code
AuthUserFile /usr/share/phpmyadmin/.htpasswd
AuthGroupFile /dev/null
AuthName "Secret"
AuthType Basic
require valid-user
<Files ~ "^.(htpasswd|htaccess)$">
    deny from all
</Files>

Press ‘Ctrl+x‘, type ‘y‘, then press ‘Enter‘ to save and exit.

Next, change the ownership of the configuration file ‘.htaccess‘ and ‘.htpasswd‘ (generated with htpasswd command) to the ‘apache‘ using the following command.

Code
chown apache:apache .htaccess .htpasswd

You need to verify the httpd configuration and make sure you have no error, then restart the httpd service to apply the new changes.

Code

sudo apachectl configtest
sudo systemctl restart httpd

 

5. Set proper permission for SELinux policies #

If your system has an enabled SELinux, then run the below command to set the appropriate permission for SELinux policies, so that we can access this GUI app without any limitation.

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

 

6. Access phpMyAdmin Web interface #

Open your web browser and type your server IP address following with the directory path ‘/phpmyadmin

Code
http://your-server-ip-address/phpmyadmin
or
http://your-domain.com/phpmyadmin

Enter the username and password of your MySQL root user to access all the databases.

How to Install phpMyAdmin on AlmaLinux 8
How to Install phpMyAdmin on AlmaLinux 8

Now you will get the phpMyAdmin dashboard as below.

On the top screenshot, you will see details of the MariaDB database server. Also, you will see the details of LAMP Stack under the ‘Web server’ section.

 

7. Create phpMyAdmin default Storage database #

If you have not manually created a dedicated database for phpMyadmin then as you log in, the same will be asked by the software to create.

At the bottom, you will see a message “ThephpPMyAdmin configuration storage is not completely configured, some extended features have been deactivated.” Click on the “Find out why link.

Now, another page will open, click on the “Create” link to generate a database name ‘phpymyadmin‘ to complete the configuration storage setup.

That’s it, you have successfully removed the warning and have set up all the required things to manage your MySQL database graphically.

congratulations! Now the installation is completed successfully!

Powered by BetterDocs