Skip to main content

Installing Apache on CentOS

By April 12, 2013No Comments

We will first create a new logical volume and copy the contents of the CentOS installation DVD to the new volume. With that in place we install the Apache web server into CentOS 6.3 with yum:

		yum search all httpd
		yum install httpd-manual httpd

Next CentOS will require us to set the ServerName property , this is set in the /etc/httpd/conf/httpd.conf file

		ServerName CENTOS63.example.local:80

We have place the CentOS install file in the /install directory of the file-system. As this is not under the normal web server directory path of/var/www/html we will create an alias file that redirects a URL though to this directory. We will create the file : /etc/httpd/conf.d/install.conf for this purpose

		Alias /install/  /install/
		<directory /install >
		  Options Indexes
		  AllowOverride None
		  Order allow,deny
		  Allow from all
		<directory >

We can test this configuration before we start the webserver with apache2ctl configtest. If that all reports OK we just need to set up SELinux if we are using it. SELinux adds additional security beyond file-system permissions and controls what services can do to certain files. We need to make sure that the web server can read the installation files by changing the security context of the /install directory and contents:
chcon -Rv –type httpd_sys_content_t
Finally we can start the service with service httpd start and set it to auto-start with chkconfig httpd –level 35 on. You may also need to check the status of your firewall to see if it permits incoming port 80 traffic.