Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (29.3k points)

I created a user with the password but once I go to my index.html page, it doesn't ask for user credentials. Refer to the attachment. Please help.

1 Answer

0 votes
by (50.2k points)
edited by

Follow the below steps to replicate the correct configs:

sudo htpasswd -c /etc/apache2/.htpasswd <user-name>

Enter Password and confirm

sudo nano /etc/apache2/sites-enabled/000-default.conf

Add the following text:

<Directory "/var/www/html">
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Directory>

This should be inside VirtualHost tag

sudo service apache2 restart

sudo nano /etc/apache2/apache2.conf

Change the highlighted entry to all in the doc

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

​sudo nano /var/www/html/.htaccess

enter the following content:

AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user

sudo service apache2 restart

For more information, check out this apache spark.

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.6k answers

500 comments

108k users

Browse Categories

...