Tuesday, February 21, 2012

How do I password protect my website

To password protect your website, please follow these steps:

Log into your Linux web server via Secure Shell (SSH).

Change into the directory you wish to password protect.

Note: If you wish to protect your entire website us the following command:

cd /vservers/username/htdocs

Create a file called .htaccess using the following command:

pico .htaccess

Enter the following information:

AuthType Basic
AuthName "Please enter your Username and Password"
AuthUserFile /vservers/username/htdocs/.htpasswd
AuthGroupFile /dev/null
Require valid-user

Press ctrl+o to save the file.

Press ctrl+x to exit the file.

Create the .htpasswd file using the following command:

/usr/bin/htpasswd -c /vservers/username/htdocs/.htpasswd username

Enter the password you wish to use.

Re-enter the password.

Grant read access to each file using the following commands:

chmod a+r .htaccess

chmod a+r .htpasswd

0 comments:

Post a Comment