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

  1.  
  2. wget http://www.gossipcheck.com/mirrors/apache/httpd/httpd-2.2.14.tar.gz
  3.  
  4. tar xvxf httpd-2.2.14.tar.gz
  5.  
  6. cd httpd-2.2.14
  7.  
  8. ./configure \
  9. --enable-so \
  10. --enable-rewrite=shared \
  11. --enable-headers \
  12. --enable-proxy \
  13. --enable-proxy-balancer \
  14. --enable-proxy-connect \
  15. --enable-proxy-http \
  16. --enable-rewrite \
  17. --enable-ssl
  18.  
  19. make
  20. make install
  21.  
  22. # Start/Stop
  23. /usr/local/apache2/bin/apachectl start
  24. /usr/local/apache2/bin/apachectl stop
  25.  

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

  1.  
  2. #
  3. # Startup script for the Apache Web Server
  4. #
  5. # chkconfig: - 85 15
  6. # description: Apache is a World Wide Web server. It is used to serve
  7. # HTML files and CGI.
  8. # processname: httpd
  9. # pidfile: /usr/local/apache/logs/httpd.pid
  10. # config: /usr/local/apache/conf/httpd.conf
  11. #
  12.  

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

Install MySql Shared Library

* Required for PHP --with-mysql configure option

  1.  
  2.  
  3.  

Install PHP 5

* Build and Compile yourself

  1.  
  2. wget http://us2.php.net/get/php-5.3.0.tar.gz/from/us3.php.net/mirror
  3. tar zxvf php-5.3.0.tar.gz
  4. cd php-5.3.0
  5.  
  6. ./configure \
  7. --with-apxs2=/usr/local/apache2/bin/apxs \
  8. --enable-bcmath \
  9. --with-pear \
  10. --enable-sockets \
  11. --with-zlib \
  12. --with-gd \
  13. --with-freetype
  14. make
  15. make install
  16.  
  17. cp php.ini-dist /usr/local/lib/php.ini
  18.  
  19. vi /usr/local/apache2/conf/httpd.conf
  20. AddHandler application/x-httpd-php .php .phtml .php3 .php4
  21.  
  22. # Not sure why we need to do this
  23. chcon -t texrel_shlib_t /usr/local/apache/modules/libphp5.so
  24.  
  25. /usr/local/apache2/bin/apachectl start
  26.  

* Use RPM Source Package

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