Answer: Do the following steps as:
1.vi /etc/httpd/conf/httpd.conf
<VirtualHost 192.100.0.1>
ServerNamewww.abc.com
DocumentRoot /var/www/abc/
<Directory /var/www/abc>
AllowOverrideauthconfig
</Directory>
DirectoryIndexindex.html
ServerAdminwebmaster@abc.com
ErrorLog logs/error_abc.logs
CustomLog logs/custom_abc.logs common
</VirtualHost>
2.Create the directory and index page on specified path. (Index page can download fromftp://server1.example.comat exam time)
3.vi /var/www/abc/.htaccess
AuthName“Only to Authorized Users”
AuthTypebasic
AuthUserFile/etc/httpd/conf/mypasswd
requirevalid-user
htpasswd –c /etc/httpd/conf/mypasswd user5
htpasswd –m /etc/httpd/conf/mypasswd user6
chgrp apache /etc/httpd/conf/mypasswd
chmod g+r /etc/httpd/conf/mypasswd
service httpd restart
chkconfig httpd on
AllowOverride Authconfig is used to specify which and how much configuration can be overridden by directory specific .htaccess files.
One of the most common tasks performed in users’ .htaccess files is adding authorization. Typically, a user will setup authorization for directories that hold sensitive information with a configuration.
Submit