Last modified: Feb. 14, 2009
Contents
1 - Summary
2 - Dependencies
3 - Apache installation
4 - Service configuration
5 - Service check
1 - Summary
This guide will show how to compile and install apache from source in Red Hat
Enterprise Linux. Apache is web server software. This has been tested in Red
Hat Enterprise Linux 5.
2 - Dependencies
You will need the following package installed to compile apache from source.
gcc-*
# rpm -qa | grep gcc-*
3 - Apache installation
Apache can be downloaded at http://httpd.apache.org/. This will be downloaded,
compiled and installed from source. Apache will be installed to
/usr/local/apache2.
# cd ~
# wget http://$mirror/httpd/httpd-*.tar.gz
# tar -zxvf httpd-*.tar.gz
# cd httpd-*/
# ./configure
# make
# sudo make install
# sudo make clean
4 - Service configuration
Find where the apache daemon was installed to.
# sudo find /usr/local/apache2 -name httpd
/usr/local/apache2/bin/httpd
Copy the init.d script to the correct location. Edit it to have the following.
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# cd ~
# sudo cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/apache
# sudo vi /etc/rc.d/init.d/apache
Enable the apache service so that it will start when the system starts.
# sudo /sbin/chkconfig --add apache
# sudo /sbin/chkconfig apache on
# sudo /sbin/chkconfig --list apache
apache 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Find where the configuration file should be put.
# sudo grep httpd.conf /etc/rc.d/init.d/apache
echo Please edit httpd.conf to include the SSL configuration settings
# sudo strings /usr/local/apache2/bin/httpd | grep httpd.conf
-D SERVER_CONFIG_FILE="conf/httpd.conf"
conf/httpd.conf
conf/httpd.conf
directive in your httpd.conf file to list a non-root
You can now create your own httpd.conf file.
# sudo find /usr/local/apache2 -name httpd.conf
/usr/local/apache2/conf/original/httpd.conf
/usr/local/apache2/conf/httpd.conf
# sudo cp /usr/local/apache2/conf/httpd.conf /usr/local/apache2/conf/httpd.conf.example
# sudo vi /usr/local/apache2/conf/httpd.conf
You will need to configure SELinux appropriately. SELinux status can be
found by running sestatus.
# sudo sestatus | grep status:
SELinux status: enabled
Start the apache service. With the default configuration file the pid file
is in /usr/local/apache2/logs.
# sudo /sbin/service apache start
# sudo cat /usr/local/apache2/logs/httpd.pid
6403
5 - Service check
Reboot your computer. Log in like normal and check to see that the apache
service is running. That's it, now you have apache running in Red Hat
Enterprise Linux.
# sudo /sbin/shutdown -r now
# sudo ls -1 /usr/local/apache2/logs/httpd.pid
/usr/local/apache2/logs/httpd.pid
# sudo cat /usr/local/apache2/logs/httpd.pid
4546
|