Edit the configuration file:
#  vim  /etc/httpd/conf/httpd.conf
Press ‘shift+g‘ to go at the end of file, and add:

<Directory “/var/www/html”>
AuthType Basic
AuthName “Authorized Users only”
AuthUserFile  /etc/httpd/authpass
Require user user1 user2                     //add all usernames
</Directory>

 

#  htpasswd  -b  /etc/httpd/authpass [username]  [password]

#service httpd restart

http://127.0.0.1 (it will ask for username and password for accessing the website.)

OR edit  “/etc/hosts”, add

127.0.0.1                     http://www.abc.com

Access www.abc.com from browser.

Advertisements