Installing Apache (httpd) version 2.x on Red Hat based systems (Inc CentOS)

Install apache web server (httpd)
yum install httpd
Start apache (httpd) daemon
/etc/init.d/httpd start
Set httpd to start at init levels 3, 4, 5 (This way it will start at the next system restart automatically)
/usr/sbin/chkconfig --level 345 httpd on
Note down the Servers IP Address (e.g. “inet addr:123.123.123.123”)
/sbin/ifconfig
Open a web browser and check you can get a default test page from the webserver.
Open Firefox or IE and browse to http://123.123.123.123

Default location of httpd logs to troubleshoot problems:
cd /var/log/httpd tail error_log tail access_log
Default location of configuration files
cd /etc/htttpd/conf/ vim httpd.conf
Set the ServerName in httpd.conf
Set the ServerName to the server’s hostname (e.g. srv-web-001) to resolve the following warning on startup.
“Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName”
Test your new config before restarting httpd
/usr/sbin/apachectl –t
Restart httpd
/etc/init.g/httpd restart
Note: This will kill off all the current httpd processes before it starts a new parent process.
OR
/etc/init.d/httpd graceful
Note: This will kill the parent process and then starts a new one with your new config. This way it leaves the child processes to complete and then when a new child process is required it starts from the new parent process hence using the new configuration file. Using this method saves disrupting connected users.

A list of all the configuration directives can be found here:
http://httpd.apache.org/docs/2.0/mod/quickreference.html
Place your HTML web content in the default document root.
This is a very basic setup of apache that will currently only serve up one site from your default document root “/var/www/”.
Place your html files into “/var/www/html/”
For example create a file named index.html and insert the following to test your setup further.

Share this blog post on social media:

Social Links

Disclaimer

All advice, installation/configuration how to guides, troubleshooting and other information on this website are provided as-is with no warranty or guarantee. Whilst the information provided is correct to the best of my knowledge, I am not reponsible for any issues that may arise using this information, and you do so at your own risk. As always before performing anything; check, double check, test and always ensure you have a backup.

Copyright ©2008-2021 Andy Barnes - Please do not copy any content including images without prior consent!

Designed and Hosted by Andy Barnes

We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.