Password protect with .htaccess & .htpasswd

Make changes to default.config

sudo nano /etc/apache2/sites-enabled/000-default.conf

Add the following inside the block <VirtualHost *:80>

<Directory /var/www/html>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride All
 Order allow,deny
 allow from all
</Directory>

Apply new changes

sudo service apache2 restart

 

Create a .htaccess file

sudo nano /usr/share/phpmyadmin/.htaccess
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user

For Authentication

sudo apt-get install apache2-utils

Add user and change password @ /etc/phpmyadmin/.htpasswd

sudo htpasswd -c /etc/phpmyadmin/.htpasswd username
sudo htpasswd /etc/phpmyadmin/.htpasswd username

You may want to store the .htpasswd at common location for sharing password authentication

Leave a Reply

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

Scroll to top