Table of Contents
Install Apache
This page shows how to install the Apache HTTP Server on CentOS 6 64bit.
Prerequisites
You must have a CentOS machine already set up in accordance with the the Install CentOS 6 guide.
If you have only installed the minimal system, you will have to run the following command as root
yum -y install wget unzip man policycoreutils-python
Install Apache
Install the version of Apache web server that comes bundled with CentOS 6
yum -y install httpd
Configure Apache web server to start automatically on system boot.
chkconfig httpd on
Open port 80 in the firewall to ensure that the website is visible to other machines. Then save the rule and restart the firewall. You may also want to open up port 443 for SSL connections.
iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT service iptables save service iptables restart
Fix Permissions
SELinux will prevent pages in other parts of the file system from being accessed unless we tell SELinux that we want to server http pages from it. Run the following commands to configure SELinux correctly. In this example, we are allowing access to data under
/data/www
semanage fcontext -a -t httpd_sys_content_t "/data/www(/.*)?" restorecon -R -v /data/www
Change Root Dir
If we need to edit the Apache web server configuration file to tell it to look at /data/www for webpages. Run the following command to find and replace var/www with data/www.
sed -i "s/var\/www/data\/www/g" /etc/httpd/conf/httpd.conf
Fix Firefox Bug
Ensure that Firefox can cope with odd css files.
echo 'AddType text/css .css' >> /etc/httpd/conf/httpd.conf
Start the Apache web server.
service httpd start
Visit http://hostname/ to see if the web server is running.
Securing Apache
To ensure that people can't abuse the debug mode of apache, edit /etc/httpd/conf/httpd.conf and put this at the end
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
