How To Set Up Password Authentication with Apache on Ubuntu 14.04
How To Set Up Password Authentication with Apache on Ubuntu 14.04
If you want to restrict access to certain pages on your Apache web server, you can set up password authentication. This tutorial will show you how to do so on Ubuntu 14.04.
Step 1: Install Apache
If you haven't already installed Apache, you can do so by running the following command:
sudo apt-get install apache2
Step 2: Create a Password File
Create a file that will hold the usernames and passwords for the users who are allowed to access your web pages:
sudo htpasswd -c /etc/apache2/.htpasswd username
Replace username with the username you want to use.
Step 3: Configure Apache
Open the Apache configuration file:
sudo nano /etc/apache2/sites-available/default
Add the following lines within the <Directory /> tags:
Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all AuthType Basic AuthName "Restricted Content" AuthUserFile /etc/apache2/.htpasswd Require valid-user
Step 4: Restart Apache
Restart Apache for the changes to take effect:
sudo service apache2 restart
Now, when a user tries to access the restricted content on your website, they will be prompted to enter a username and password.
Keywords: password authentication, Apache, Ubuntu 14.04, install Apache, create password file, configure Apache, restart Apache.
Комментарии
Отправить комментарий