Skip to content

Instantly share code, notes, and snippets.

@geenloop
Created April 28, 2019 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geenloop/d545c5a762994a8202304fda7502cacd to your computer and use it in GitHub Desktop.
Save geenloop/d545c5a762994a8202304fda7502cacd to your computer and use it in GitHub Desktop.
Password Authentication with Apache
apt-get update
apt-get install apache2-utils
htpasswd -c /etc/apache2/.htpasswd user
nano /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/html">
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Directory>
</VirtualHost>
apache2ctl configtest
systemctl restart apache2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment