How to Secure PHPMyAdmin CentOS 8

How to Secure PHPMyAdmin CentOS 8

There are 3 simple ways to secure PHPMYADMIN access in centos 8, in which first we can change the login URL of PHPMyAdmin. In another way, we can allow specific IP. And in a third way, we can password protected PHPMyAdmin login access. So in these three ways, we can secure our login access in centOS with apache.

Secure PHPMyAdmin on CentOS 8 with apache; Through this tutorial, we will learn three simple ways on how to secure PHPMyAdmin in CentOS 8 system with apache.

How to Secure PHPMyAdmin CentOS 8

Use the following three different ways to secure your phpMyAdmin web interface in CentOS 8:

  • Change phpMyAdmin Access Location
  • Allow phpMyAdmin from Specific IP
  • Password Protect phpMyAdmin Interface

Change phpMyAdmin Access Location

It is a good idea to change the access URL of your phpMyAdmin interface. You can change it by editing the phpmyadmin.conf file:

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

Find the following line:

Alias /phpmyadmin /var/www/html/phpmyadmin

Replace it with the following line:

Alias /securelocation /var/www/html/phpmyadmin

Save and close the file, then restart the Apache service to implement the changes:

systemctl restart httpd

You can now access the phpMyAdmin interface using the URL http://your-server-ip/securelocation.

Allow phpMyAdmin from Specific IP

It is always a good idea to allow phpMyAdmin only to be accessible from a specific IP address.

To do so, open the phpmyadmin.conf file:

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

Find the following lines:

     <RequireAny>
       Require all granted
     </RequireAny>

Replace it with the following:

<RequireAny>
    Require ip your-client-ip-address
    Require ip ::1
</RequireAny>

Save and close the file, then restart the Apache service to implement the changes:

systemctl restart httpd

Your phpMyAdmin interface is now only accessible from a specified IP address.

Password Protect phpMyAdmin Interface

You can also add an extra layer of password protection on phpMyAdmin by setting up basic authentication.

First, create an authentication file using the following command:

htpasswd -c /etc/httpd/.htpasswd phpadmin

Provide a secure password as shown below:

New password:
Re-type new password:
Adding password for user phpadmin

Next, create the .htaccess file within the phpmyadmin directory:

nano /var/www/html/phpmyadmin/.htaccess

Add the following lines:

AuthType basic
AuthName "Authentication Required"
AuthUserFile /etc/httpd/.htpasswd
Require valid-user

Save and close the file when you are finished.

Next, edit the phpmyadmin.conf file and configure Apache to use the .htpasswd file.

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

Add the following lines below the line “AddDefaultCharset UTF-8”:

    AllowOverride All

Save the file, then restart the Apache service to implement the changes:

systemctl restart httpd

Now, To test it, so open web browser and type the URL http://your-server-ip/securelocation.

Conclusion

Through this tutorial, we have learned how to install and secure phpMyAdmin on CentOS 8. And our phpMyAdmin interface is now secured with additional password protection.

Recommended CentOS Tutorials

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

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