yum install httpd-tools
I put .htaccess in /var/www/html
AuthName “Restricted Access”
mkdir -p /usr/local/apache/passwd
# Create as many usernames as you need.
htpasswd -c /usr/local/apache/passwd/wwwpasswd someusername
htpasswd -c /usr/local/apache/passwd/wwwpasswd someotherusername
Alternatively, the authentication can be added to the bottom of /etc/httpd/conf/httpd.conf as follows.
AuthName “Restricted Area”
If browser http access is only required from certain IP addresses or ranges of addresses.
Deny from all
Allow from x.x.x.x
Allow from x.x.x.x x.x.x.x x.x.x.x
Allow from somedomain.com
Allow from x.x
Allow from x.x.x.0/255.255.255.0
#See http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html for more examples
yum install mod_ssl
creating the self-signed SSL certificate and the server key that protects it, and placing both of them into the new directory.
openssl req -x509 -nodes -days 730 -newkey rsa:2048 -keyout /etc/httpd/ssl/apache.key -out /etc/httpd/ssl/apache.crt
Find the following three lines, and make sure that they match the extensions below: