Dave's Brain

Browse - Computer Tips - How can I setup Basic Authentication with Apache 2.4?

Date: 2015aug18
Product: Apache 2.4

Q.  How can I setup Basic Authentication with Apache 2.4?

A.  

Ensure .htaccess files are allowed - check your main .conf file:

<Directory /var/www> AllowOverride AuthConfig <Directory>
Put this in an .htaccess file:
AuthType basic AuthUserFile /etc/httpd/conf/passwd AuthGroupFile /dev/null AuthName basic_test <LIMIT GET> require user myuser </LIMIT>
Create the user file like this:
htpasswd -c /etc/httpd/conf/passwd myuser
And you'll be prompted for a password. Things to note: - The file user file can be anywhere. But its not safe to put in your webtree. - Can be in a .conf file rather than .htaccess

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.