Overview

Installing Apache ( 2.2.17 ) , Mysql ( 5.1.54 ) and php ( 5.3.4 ) on a Centos server.

Requirements

Centos Server

Objective

Building from source an optimised/light Apache-Mysql-PHP on top of Centos server

Configuration

Step 1

Install Mysql

root@serv:~# groupadd mysql

root@serv:~# useradd -r -g mysql mysql

root@serv:~# cd /usr/local

root@serv:~# wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.54-linux-i686-glibc23.tar.gz/from/http://mysql.easynet.be/

root@serv:~# gunzip < /usr/local/mysql-5.1.54-linux-i686-glibc23.tar.gz | tar xvf –

root@serv:~# ln -s /usr/local/mysql-5.1.54-linux-i686-glibc23 mysql

root@serv:~# cd mysql

root@serv:~# chown -R mysql .

root@serv:~# chgrp -R mysql .

root@serv:~# scripts/mysql_install_db –user=mysql

root@serv:~# chown -R root .

root@serv:~# chown -R mysql data

root@serv:~# cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf

root@serv:~# bin/mysqld_safe –user=mysql &

root@serv:~# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

root@serv:~# ln -s /usr/local/mysql/bin/* /usr/bin/

Step 2

Install Apache , also install the dependent packages and compilers. You have to install the below packages for the most needed compile options that I have used.

root@serv:~# yum install gcc zlib-devel openssl-devel make

root@serv:~# cd /usr/local/src/

root@serv:~# wget http://www.alliedquotes.com/mirrors/apache//httpd/httpd-2.2.17.tar.bz2

root@serv:~# tar -jxvf httpd-2.2.17.tar.bz2

root@serv:~# cd /usr/local/src/httpd-2.2.17

root@serv:~# ./configure –prefix=/usr/local/apache –host=i686-redhat-linux-gnu –build=i686-redhat-linux-gnu –target=i386-redhat-linux  –enable-deflate –enable-proxy –enable-proxy-http—enable-proxy-connect –enable-so –enable-cgi –enable-info –enable-rewrite –enable-speling –enable-usertrack –enable-deflate –enable-mime-magic –enable-ssl

root@serv:~# make

root@serv:~# make install

Step 3

Install php, as we did before you need to install the dependencies before the php installation

root@serv:~# cd /usr/local/src/

root@serv:~# wget http://in2.php.net/get/php-5.3.4.tar.bz2/from/us.php.net/mirror

root@serv:~# tar -jxvf php-5.3.4.tar.bz2

root@serv:~# cd /usr/local/src/php-5.3.4/

root@serv:~# yum install libxml2-devel pcre-devel bzip2-devel curl-devel libjpeg-devel libpng-devel libXpm-devel libc-client-devel libmcrypt-devel libmcrypt-devel expat-devel

root@serv:~# ./configure –with-apxs2=/usr/local/apache/bin/apxs –enable-bcmath –enable-calendar –enable-ftp –enable-libxml –enable-magic-quotes –enable-pdo=shared –enable-soap –enable-sockets –enable-zip –prefix=/usr –with-bz2 –with-curl=/opt/curlssl/ –with-gd –with-imap=/opt/php_with_imap_client/ –with-imap-ssl=/usr –with-jpeg-dir=/usr –with-kerberos –with-libexpat-dir=/usr –with-libxml-dir –with-libxml-dir –with-mcrypt=/opt/libmcrypt/ –with-mhash=/opt/mhash/ –with-mysql=/usr/local/mysql/ –with-mysql-sock –with-openssl=/usr –with-openssl-dir=/usr –with-pcre-regex –with-pdo-mysql=shared –with-pdo-sqlite=shared –with-png-dir=/usr –with-sqlite=shared –with-xmlrpc –with-xpm-dir=/usr –with-zlib –with-zlib-dir=/usr

root@serv:~# make

root@serv:~# make install
Step 4

Configure php to phrase .php extension as php

root@serv:~# vi /usr/local/apache/conf/httpd.conf

find the line “LoadModule php5_module modules/libphp5.so” add the below line after it.
AddType application/x-httpd-php .php

root@serv:~# /usr/local/apache/bin/apachectl restart

Step 5

That is it, you can now test your installation

echo “<?php phpinfo(); ?> ” > /usr/local/apache/htdocs/phpinfo.php

Access and check your phpinfo page with,
http://your_server_ip/phpinfo.php