Created
April 28, 2019 17:06
-
-
Save geenloop/d545c5a762994a8202304fda7502cacd to your computer and use it in GitHub Desktop.
Password Authentication with Apache
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
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