Skip to content

Instantly share code, notes, and snippets.

@rgwozdz
Last active December 23, 2015 06:59
Show Gist options
  • Save rgwozdz/6598074 to your computer and use it in GitHub Desktop.
Save rgwozdz/6598074 to your computer and use it in GitHub Desktop.
Apache basic authentication setup.
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