Install Apache 2 and PHP 5 on RHEL 5

 

Dependencies

* Make sure following packages are installed: bison flex gcc db4 db4-devel libxml2-devel libpng-devel. Installed if not already with

yum install bison flex gcc db4 db4-devel libxml2-devel libpng-devel

Install Apache 2

wget http://www.gossipcheck.com/mirrors/apache/httpd/httpd-2.2.14.tar.gz
 
tar xvxf httpd-2.2.14.tar.gz
 
cd httpd-2.2.14
 
./configure \
  --enable-so \
  --enable-rewrite=shared \
  --enable-headers \
  --enable-proxy \
  --enable-proxy-balancer \
  --enable-proxy-connect \
  --enable-proxy-http \
  --enable-rewrite \
  --enable-ssl
 
make
make install
 
# Start/Stop
/usr/local/apache2/bin/apachectl start
/usr/local/apache2/bin/apachectl stop

Auto Start Apache 2

* cp /usr/local/apache2/bin/apachectl /etc/init.d
* chmod 755 /etc/init.d/apachectl

* Add to /etc/init.d/apachectl right below #!/bin/sh with comments on

#
# Startup script for the Apache Web Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve
# HTML files and CGI.
# processname: httpd
# pidfile: /usr/local/apache/logs/httpd.pid
# config: /usr/local/apache/conf/httpd.conf
#

* /sbin/chkconfig –add apachectl
* /sbin/chkconfig –level 35 apachectl on

Install MySql Shared Library

* Required for PHP –with-mysql configure option

 

Install PHP 5

* Build and Compile yourself

wget http://us2.php.net/get/php-5.3.0.tar.gz/from/us3.php.net/mirror
tar zxvf php-5.3.0.tar.gz
cd php-5.3.0
 
./configure \
  --with-apxs2=/usr/local/apache2/bin/apxs \
  --enable-bcmath \
  --with-pear \
  --enable-sockets \
  --with-zlib \
  --with-gd \
  --with-freetype
make
make install
 
cp php.ini-dist /usr/local/lib/php.ini
 
vi /usr/local/apache2/conf/httpd.conf
  AddHandler application/x-httpd-php .php .phtml .php3 .php4
 
# Not sure why we need to do this
chcon -t texrel_shlib_t /usr/local/apache/modules/libphp5.so
 
/usr/local/apache2/bin/apachectl start

* Use RPM Source Package

wget ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Server/en/os/SRPMS/php-5.1.6-23.2.el5_3.src.rpm
rpm --rebuild php-5.1.6-23.2.el5_3.src.rpm
cd /usr/src/redhat/RPM/
rpm -iv php-5.1.6-23.2.el5_3.rpm
This entry was posted in apache, Linux. Bookmark the permalink.