Add the following to .htaccess:
CentOS:
AuthType Basic
AuthName “Restricted”
AuthUserFile /etc/httpd/htaccess-pass
Require valid-user
#Order deny,allow
#Deny from All
#Satisfy any
Create the file as follows:
htpasswd /etc/httpd/htaccess-pass username
You will then be prompted for a password
Ubuntu:
AuthType Basic
AuthName “Restricted”
AuthUserFile /etc/apache2/htaccess-pass
Require valid-user
#Order deny,allow
#Deny from All
#Satisfy any
Create the file as follows:
htpasswd /etc/apache2/htaccess-pass username
You will then be prompted for a password