Skip to content

Instantly share code, notes, and snippets.

@florentdestremau
Last active August 29, 2015 14:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save florentdestremau/61ea35d0d27728f759da to your computer and use it in GitHub Desktop.
Save florentdestremau/61ea35d0d27728f759da to your computer and use it in GitHub Desktop.
Enable apache auth for websites under construction
First of all, you need uapache2-utils tools.
sudo apt-get install apache2-utils
Then you add this in your virtualhost in your <Directory> tag :
#Require all granted
# you need to comment this line above to require a valid-user
AuthName "This website is not ready to go public !"
AuthType Basic
AuthUserFile /var/www/.htpasswd
require valid-user
The `AuthUserFile` can be created anywhere, just has to be readable, i find www/ apropriate (it's not a security matter, just privacy).
Then you create your user:
htpasswd -c /usr/local/etc/httpd/users name-of-your-user
You will be prompted the password
Finally
sudo service apache2 restart
Not sure if restart is needed instead of reload but under developement who cares :3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment