23 February 2013

Installing apache 2.4.x and php 5.3.x from source on Centos

I used apache 2.4.3 and php 5.3.22 for this guide.
Before installing anything from the source you need to remove old libs/packages from the Centos. You can remove PHP by typing:
yum remove php
run following command to remove other php-libs:
yum remove php-cli php-gd php-mysql php-mbstring
There is no need to uninstall the existing apache http server, however you need to stop the process for new installation of apache httpd to work.
Prerequisites:
  • Create a directory where you will download the tars, e.g. /usr/tmp/
  • cd to this directory
  • Download the src of apache web server, apr, apr-util and php by using following commands:
wget http://apache.techartifact.com/mirror//httpd/httpd-2.4.3.tar.gz
wget http://apache.techartifact.com/mirror//apr/apr-1.4.6.tar.gz
wget http://apache.techartifact.com/mirror//apr/apr-util-1.5.1.tar.gz
wget http://www.php.net/get/php-5.3.22.tar.gz/from/us1.php.net/mirror
You also need to install gcc and openssl-devel (for ssl support).
yum install gcc
yum install openssl-devel
Installing Apache HTTP Server:
Extract all the 4 archives downloaded in the /usr/tmp/ dir using following command:
tar xvfz httpd-2.4.3.tar.gz
tar xvfz apr-1.4.6.tar.gz
tar xvfz apr-util-1.5.1.tar.gz
tar xvfz php-5.3.22.tar.gz
cd to the httpd-2.4.3 and run the following command (if you want to install Apache with ssl support add --enable-ssl option):
./configure --enable-so --with-apr=/usr/tmp/apr-1.4.6 --with-apr-util=/usr/tmp/apr-util-1.5.1
Run following commands to install the Apache:
make
make install
Start the Apache server using the command:
/usr/local/apache2/bin/apachectl start
Installing PHP:
cd to php-5.3.22 directory and run the following command to see the configuration options available with PHP installation:
./configure --help
Select the php modules you want to install, also add the --with-apxs2 option to configure the php with Apache server we installed, following command contains common php modules:
./configure  --with-apxs2=/usr/local/apache2/bin/apxs --disable-debug --enable-inline-optimization --enable-mbregex --enable-gd-native-ttf --enable-mbstring --enable-zend-multibyte --enable-sockets --enable-sysvsem --enable-sysvshm --enable-zip --with-gettext --with-mcrypt --with-mhash --with-openssl --with-pcre-regex --with-pear --with-zlib --with-xsl 
Compile and install the PHP:
make
make install
Restart the Apache server and you are done. I have tested this on Centos 5.x but it should work on Centos 6.x. Following are the important paths:
  • Default web directory, where your all web stuff go: /usr/local/apache2/htdocs
  • http.conf path:/usr/local/apache2/conf/httpd.conf
  • php.ini path:/usr/local/lib/php.ini

No comments:

Post a Comment