######### Creating a Passowrd Protected Website #################
1. Create your default website and check its working on browswer
When the website is working
2. Create a htpasswd file in /etc/httpd/conf/
[root@dhcppc9 conf]# htpasswd -c .htpasswd mind
New password:
Re-type new password:
Adding password for user mind
3. Set .htpasswd file permission 0644 so that it is accessed to apache user and group of apache server.
chmod 0644 .htpasswd
4. Now create .htaccess file in your document root where the website is placed (/var/www/html/site1)
#vim /var/www/html/site1/.htaccess
Now paste the following lines in this file
AuthType Basic
AuthName "Restricted Area"
AuthUserFile /etc/httpd/conf/.htpasswd -- path of htpasswd file
require valid-user
5. set permission 0644 to this file so that it is access to apache user and group.
[root@dhcppc9 conf]# chmod 0644 /var/www/html/site1/.htaccess
6. Now open httpd.conf file and paste the following lines in your virutal host
<Directory "/var/www/html/site1"> --- path of your document root
AllowOverride AuthConfig
# The Options below is an example. Use what you deem is necessary.
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Order allow,deny
Allow from all
</Directory>
7. Service httpd restart
Wednesday, 10 April 2013
How to create Password protected website on Apache in Centos 6
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment