Prerequisites
You will need a running ubuntu server to follow the steps in this article.
Setup
- Enter in terminal:
sudo apt-get update sudo apt-get install apache2 apache2-utils sudo htpasswd -c /etc/apache2/.htpasswd some-username sudo nano /etc/apache2/sites-enabled/000-default.conf
- Add:
<Directory "/var/www/html"> AuthType Basic AuthName "Restricted Content" AuthUserFile /etc/apache2/.htpasswd Require valid-user </Directory>
Replace /var/www/html with the path to the directory you want to restrict access to. sudo service apache2 restart
Voila!