How to protect a web folder using HTTP Basic Authentication with Apache2

Run the following to create a password file and enter your password

htpasswd -c /etc/httpd/passwd/myverysecrepasswords admin

-c flag means create a new file

Edit the following accordingly your needs and append into your httpd.conf file

<Directory "/var/www/html/mysecure">
AuthType Basic
AuthName "Protected Files"
AuthBasicProvider file
AuthUserFile /etc/httpd/passwd/myverysecrepasswords
Require user admin
</Directory>

 

Common paths where httpd.conf usually stored:

/usr/local/apache2/httpd.conf
/etc/httpd/conf/httpd.conf
/etc/apache2/conf/httpd.conf

Enjoy!

Similar Posts:

Leave a Reply

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