I have used Red Hat 6 machine for these commands so kindly check the same if planning to user other distribution of Linux.
These are the required attributes which has to be placed and used properly inside the main apache configuration file.
This option will disable the access to read .htaccess file
This option with enable the access to read .htaccess file
This will signify the authentication file for required user
This will give an output name which you want to be visible on the login prompt screen
AuthName "Restricted Area"
NOTE: Create a new .htaccess file inside the directory where you want the authentication. In our case it is inside /var/www.
Create a authentication file inside the directory you want to protect.
# htpasswd /var/www/.htaccess username
# htpasswd /var/www/.htaccess deepak
Re-type new password:
Adding password for user deepak
Give appropriate permission to prevent anauthorized access
# chmod 700 /var/www/.htaccess
Add these lines at the end of the config file for apache
# vi /etc/httpd/conf/httpd.conf
AuthName "Login Message on the prompt screen"
Require user deepak
Allow from all
How to register Red Hat Linux with RHN (Red Hat Network )
Red hat Enterprise Linux 5.5 Installation Guide (Screenshots)
15 tips to enhance security of your Linux machine
Why is Linux more secure than windows and any other OS
What is the difference between "su" and "su -" in Linux?
What is swappiness and how do we change its value?
How to log iptables messages in different log file
What are the s and k scripts in the etc rcx.d directories
How to check all the currently running services in Linux
How to auto start service after reboot in Linux
What is virtual memory, paging and swap space?