Before installing anything from the source you need to remove old libs/packages from the Centos. You can remove PHP by typing:
yum remove phprun following command to remove other php-libs:
yum remove php-cli php-gd php-mysql php-mbstringThere 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/mirrorYou also need to install gcc and openssl-devel (for ssl support).
yum install gcc yum install openssl-develInstalling 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.gzcd 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.1Run following commands to install the Apache:
make make installStart the Apache server using the command:
/usr/local/apache2/bin/apachectl startInstalling PHP:
cd to php-5.3.22 directory and run the following command to see the configuration options available with PHP installation:
./configure --helpSelect 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-xslCompile and install the PHP:
make make installRestart 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