Last active
December 23, 2015 06:59
-
-
Save rgwozdz/6598074 to your computer and use it in GitHub Desktop.
Apache basic authentication setup.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Open the http.conf file for editing: | |
# sudo pico /etc/apache2/http.conf. | |
2) Add specifics for each var/www directory to be placed under Basic Authentication: | |
<Directory "/var/www/my-web-app-directory"> | |
AuthUserFile /etc/apache2/htpasswords | |
AuthName "Some silly message." | |
AuthType Basic | |
Require valid-user | |
AllowOverride None | |
Order allow,deny | |
allow from all | |
</Directory> | |
3) Save and close pico editor | |
4) Add user and pwd with "htpasswd" command: | |
# htpasswd -c /etc/apache2/htpasswords the-app-user | |
New password: mypassword | |
Re-type new password: mypassword | |
Adding password for user the-app-user | |
5) Add an .htaccess file to your web app directory. Blank/empty is fine. | |
6) Restart apache: | |
# sudo /etc/init.d/apache2 restart | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment