|
How to create password protected directory in CentOS
For this example I take following directories to host the website: /home/user/ahamed/www
1. Create .htaccess file in /home/user/ahamed/www/.htaccess with following info (added ahamed as a user in .htaccess file)
AuthUserFile /etc/.htpasswd AuthGroupFile /dev/null AuthName "SECURE AREA NAME" AuthType Basic
<Limit GET>
require user ahamed
</Limit>
2. Create .htpasswd file in /etc/.htpasswd type following ssh command to create the file, it will ask for password after typing bellow command htpasswd -c /etc/.htpasswd ahamed
3. locate httpd.conf file and edit the file and add following code
<Directory "/home/user/ahamed/www">
AllowOverride AuthConfig
</Directory>
4. restart apache using following command service httpd restart |