Install the “Web Server” package group:
# yum groupinstall -y "Web Server"
Edit the /etc/hosts file and add the ip address and the fully qualified domain name of the server:
1.2.3.4 server.example.com
To allow only a group of users (here nikos and steve from the team) to access a specific directory (here private), edit the /etc/httpd/conf/httpd.conf file and type:
<Directory "/var/www/html/private"> AuthType Basic AuthName "Password protected area" AuthGroupFile /etc/httpd/conf/team AuthUserFile /etc/httpd/conf/passwd Require group team </Directory>
Check the configuration file:
# service httpd configtest Syntax OK
Create the private directory:
# mkdir -p /var/www/html/private # restorecon /var/www/html/private
Create the /etc/httpd/conf/team file:
team: nikos steve
Create the /etc/httpd/conf/passwd file:
# htpasswd -c /etc/httpd/conf/passwd nikos New password:nikosRe-type new password:nikosAdding password for user nikos # htpasswd /etc/httpd/conf/passwd steve New password:steveRe-type new password:steveAdding password for user steve
Add a new rule to the firewall:
# iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
Save the firewall configuration:
# service iptables save
Activate the httpd service at boot:
# chkconfig httpd on
Start the httpd service:
# service httpd start
Check the httpd service:
# yum install -y elinks # elinks http://localhost/private/
Don’t forget this part
Alias /private/ “/var/www/html/private/”
This is not necessary.