Add basic authentication in phpMyAdmin in CentOS 7

Problem: Want to increase phpMyAdmin security, for example adding one more gateway before entering username and password in xxx/phpmyadmin

This is possible and can be achieved in two way:

Solution: first find out where the PHPMyAdmin folder

find /etc/httpd/ -print0 | xargs -0 grep phpmyadmin

then create a .htpasswd  file for the user you want, like user1.

sudo htpasswd -c /etc/httpd/.htpasswd user1

the output will look like this:

user1:$apr1$0r/2zNGG$jopiWY3DEJd2FvZxTnugJ/

Way 1 -- edit /etc/httpd/conf/httpd.conf , change into below content:

<Directory /usr/share/phpmyadmin>
    AuthType Basic
    AuthName "Restricted Content"
    AuthUserFile /etc/httpd/.htpasswd
    Require valid-user
</Directory>

Way 2 -- go to phpMyAdmin folder that finds out via the previous command, add .htaccess file with below content:

AuthType Basic
AuthName "Admin Login"
AuthUserFile /etc/httpd/pma_pass
Require valid-user

You may also like...

Leave a Reply

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

Secured By miniOrange