Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

How to Install phpMyAdmin on CentOS 7 with Nginx

November 4, 2022
in Blog
0
ADVERTISEMENT

Table of Contents

As we know that to do database management easily, we can take advantage of free open-source software tools such as phpMyAdmin. Without these two tools, we should be familiar with the MySQL or MariaDB variable system through the command line interface.

In this post, we will install and configure phpMyAdmin manually on CentOS 7 with Nginx & PHP-FPM running inside the machine.

Prerequisites

Before moving into the installation procedure make sure to meet the following requirements:

  • A vps on cloud or bare metal running under distro CentOS 7.
  • Must have NGINX and PHP-FPM installed on the machine.
  • Superuser Privileges (Root Access).
  • Server IPv4 Address & Its Password.
  • PuTTY SSH Client for Windows or Linux terminal app.

Install phpMyAdmin Manually on CentOS 7

1. First of all please directly download the latest stable release of phpMyAdmin using wget command.

cd /usr/share
sudo yum install epel-release unzip -y
sudo wget https://files.phpmyadmin.net/phpMyAdmin/5.2.0/phpMyAdmin-5.2.0-all-languages.zip

2. Extract the downloaded file phpMyAdmin-5.2.0-all-languages.zip using the unzip command and rename the extracted directory to phpmyadmin then remove the downloaded zip file from your server.

sudo unzip phpMyAdmin-5.2.0-all-languages.zip
sudo mv phpMyAdmin-5.2.0-all-languages phpmyadmin
sudo rm -f phpMyAdmin-5.2.0-all-languages.zip

3. Create a symbolic link between your phpmyadmin directory to the public folder or documents root of your NGINX web server. In this case, my site located in /var/www/bonguides.me.

Note Note: Make sure to replace with your actual domain name if you want to run phpMyAdmin.
sudo ln -s /usr/share/phpmyadmin /var/www/bonguides.me

Then I run the following command to verify the symlink was created:

ls -l /var/www/bonguides.me/
total 224
-rw-r--r--.  1 nginx nginx   405 Feb  6  2020 index.php
-rw-r--r--.  1 nginx nginx 19915 Dec 31  2021 license.txt
lrwxrwxrwx   1 nginx nginx    21 Nov  4 05:35 phpmyadmin -> /usr/share/phpmyadmin
-rw-r--r--.  1 nginx nginx  7389 Sep 16 18:27 readme.html

5. Grant permission for user nginx then restart php-fpm and nginx services.

sudo chown -R nginx: /var/www/bonguides.me
sudo chown nginx:nginx /var/lib/php/session
sudo systemctl restart php-fpm && sudo systemctl restart nginx

Finally, you can access phpMyAdmin for the first time at the following URLs:

###Using the server ip address
http(s)://server_IPv4_address/phpmyadmin

###Using domain name
http(s)://yourdomain.com/phpmyadmin
Bg2386
ADVERTISEMENT

Secure phpMyAdmin

Changing phpMyAdmin’s Default Location

One way to protect your phpMyAdmin installation is by making it harder to find. Bots will scan for common paths, like /phpmyadmin, /pma, /admin, /mysql, and other similar names.

Changing the interface’s URL from /phpmyadmin to something non-standard will make it much harder for automated scripts to find your phpMyAdmin installation and attempt brute-force attacks.

In the previous step, you created a symbolic link in your Nginx web root pointing to /usr/share/phpmyadmin, where the actual phpMyAdmin application files are located. You can rename this symbolic link to change phpMyAdmin’s interface URL.

cd /var/www/your_domain/
sudo mv phpmyadmin RKGUfVG6uM3xVsyNXpZfmAYtEssmrSv8qZ
# ls -l /var/www/bonguides.me/
...
lrwxrwxrwx  1 root  root  21 Nov 4 RKGUfVG6uM3xVsyNXpZfmAYtEssmrSv8qZ -> /usr/share/phpmyadmin
...

Now when you go to the URL you previously used to access phpMyAdmin, you’ll get a 404 error:

You can instead access your phpMyAdmin interface at the new URL you just configured.

Creating an Authentication Gateway

Hiding your phpMyAdmin installation in an unusual location might sidestep some automated bots scanning the network, but it’s useless against targeted attacks. To better protect a web application with restricted access, it’s generally more effective to stop attackers before they can even reach the application. This way, they’ll be unable to use generic exploits and brute-force attacks to guess access credentials.

1. Create an encrypted password using openssl passwd command. You will be prompted to enter and confirm the password that you wish to use. The utility will then display an encrypted version of the password that will look something like this:

# openssl passwd
Password:
Verifying - Password:
Warning: truncating password to 8 characters
KM1..mx3Z6Nnk

2. Copy this value, as you will need to include it in the authentication file you are about to create.

3. Now, create an authentication file. For the purposes of this guide, we’ll call this file pma_pass and place it in the Nginx configuration directory. 

In this example the user is named tonny, but you can choose any username you’d like. This doesn’t need to be the name of an existing user profile on your CentOS server or that of a MySQL user.

echo 'tonny:KM1..mx3Z6Nnk' >> /etc/nginx/pma_pass

4. Verify the file was created using cat command.

# cat /etc/nginx/pma_pass
tonny:KM1..mx3Z6Nnk

5. Next, you’ll need to modify the Nginx configuration file. Add the following highlighted lines within the main server block.

Note Note: Remember to replace the location with the actual path where phpMyAdmin can be found on your server.
server {
	listen 80;
	server_name bonguides.me;
    ...
    ...
    location /RKGUfVG6uM3xVsyNXpZfmAYtEssmrSv8qZ {
        auth_basic "Admin Login";auth_basic_user_file /etc/nginx/pma_pass;
        }
}
Bg2387

6. Restart the nginx and php-fpm services.

sudo systemctl restart php-fpm && sudo systemctl restart nginx

7. Now when you visit the phpMyAdmin URL in your web browser, you will be prompted for the username and password you added to the pma_pass file:

Bg2391

8. Once you enter your credentials, you’ll be taken to the standard phpMyAdmin login page.

Bg2390
ADVERTISEMENT
5/5 - (1 vote)
Previous Post

Change the Color and Background Image of the Firefox Toolbars

Next Post

How to Create Shortcuts in Linux – Symbolic Links

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory