This document outline the installation and configuration steps for the installation of the http-2.2.15 with fast cgi and mysql support 

Application Path:

Apache - /opt/app/httpd-2.2.15-fastcgi

PHP - /opt/app/php-5.2.14

Memcached - /opt/app/memcached-1.4.5

Autoconf - /opt/app/autoconf-2.13

MySQL client - /opt/app/ mysql-connector-c-6.0.2-linux-rhel5-x86-64bit

Software prerequisites: 

# wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz

# wget http://pecl.php.net/get/memcache-2.2.5.tgz

# wget http://monkey.org/~provos/libevent-1.4.13-stable.tar.gz

# wget http://www.fastcgi.com/dist/mod_fastcgi-2.4.6.tar.gz

# wget http://hk.php.net/get/php-5.2.14.tar.gz/from/this/mirror

# wget http://ftp.cuhk.edu.hk/pub/packages/apache.org/httpd/httpd-2.2.15.tar.gz

# wget http://php-fpm.org/downloads/php-5.2.14-fpm-0.5.14.diff.gz

# wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.13.tar.gz

# wget http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-6.0.2-linux-rhel4-x86-64bit.tar.gz/from/http://mysql.oss.eznetsols.org/

Install Autoconf

# tar xvf autoconf-2.13.tar.gz

# cd autoconf-2.13

# ./configure –prefix=/opt/app/autoconf-2.13

# make

# make install

Install Apache Server

# tar zxf httpd-2.2.15.tar.gz

# cd httpd-2.2.15

# ./configure --prefix=/opt/app/httpd-2.2.15-fastcgi --enable-headers --enable-deflate --enable-so --enable-proxy --enable-proxy-http --enable-proxy-ajp --enable-rewrite --enable-ssl --with-mpm=worker

# make

# make install

Install MySql client

# tar zxf mysql-connector-c-6.0.2-linux-rhel4-x86-64bit.tar.gz

Install PHP

# tar zxf php-5.2.14.tar.gz

# gzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14 -p1

# cd php-5.2.14

# export PHP_AUTOCONF=/opt/app/autoconf-2.13/bin/autoconf

# export PHP_AUTOHEADER=/opt/app/autoconf-2.13/bin/autoheader

# ./buildconf --force

# ./configure --prefix=/opt/app/php-5.2.14 [--with-apxs2=/opt/app/httpd-2.2.15/bin/apxs] --enable-bcmath --enable-mbstring --with-xsl --with-zlib --with-gd --with-jpeg-dir=/usr/lib/ --with-png-dir=/usr/lib/ --with-config-file-path=/opt/app/httpd-2.2.15-fastcgi/conf --enable-fastcgi --enable-force-cgi-redirect --enable-fpm --with-mysql=/opt/app/mysql-connector-c-6.0.2-linux-rhel5-x86-64bit --with-mysqli=/opt/app/mysql-connector-c-6.0.2-linux-rhel5-x86-64bit/bin/mysql_config

# make

# make install

Notes: [--with-apxs2=/opt/app/httpd-2.2.15/bin/apxs] – not required for using fastcgi

Install libevent

# tar zxf libevent-1.4.13-stable.tar.gz

# cd libevent-1.4.13-stable

# ./configure --prefix=/opt/app/libevent-1.4.13

# make

# make install

# cp /opt/app/libevent-1.4.13/lib/libevent-1.4.so.2 /usr/lib/

# vi /etc/ld.so.conf.d/libevent-i386.conf (add /opt/app/libevent-1.4.13/lib/)

# ldconfig

Install Memcached

# tar zxf memcached-1.4.5.tar.gz 

# cd memcached-1.4.5

# ./configure --prefix=/opt/app/memcached-1.4.5 --with-libevent=/opt/app/libevent-1.4.13

# make

# make install

Install memcache module for PHP

# tar zxf memcache-2.2.5.tgz

# cd memcache-2.2.5

# /opt/app/php-5.2.14/bin/phpize

# ./configure --with-php-config=/opt/app/php-5.2.14/bin/php-config 

# make

# make install

Create server startup script

# cp memcached /etc/init.d/

# cp start-memcached /opt/app/memcached-1.4.5/bin/

# cd /opt/app/memcached-1.4.5/

# mkdir conf

# cp memcached.conf /opt/app/memcached-1.4.5/conf/

# cd /etc/init.d

# chkconfig --add memcached

# chkconfig --level 2345 memcached on

Install fastcgi module for Apache

# tar zxf mod_fastcgi-2.4.6.tar.gz

# cd mod_fastcgi-2.4.6

# cp Makefile.AP2 Makefile

# make top_dir=/opt/app/httpd-2.2.15-fastcgi

# make install top_dir=/opt/app/httpd-2.2.15-fastcgi

Update PHP and Apache config files

# cp /opt/app/httpd-2.2.9/conf/php.ini /opt/app/httpd-2.2.15-fastcgi/conf/php.ini

# vi /opt/app/httpd-2.2.15-fastcgi/conf/php.ini

add:

extension_dir = "/opt/app/php-5.2.14/lib/php/extensions/no-debug-non-zts-20060613/"

extension=memcache.so

# vi /opt/app/httpd-2.2.15-fastcgi/conf/httpd.conf 

LoadModule fastcgi_modulemodules/mod_fastcgi.so

VirtualHost

ScriptAlias /cgi-bin/ "/opt/vhost/www.com/cgi-bin/"

FastCgiServer /opt/app/php-5.2.14/bin/php-cgi -processes 60

<Directory "/opt/vhost/www.com">

Options -Indexes FollowSymLinks +ExecCGI

AllowOverride AuthConfig FileInfo

AddHandler php5-fastcgi .php

Action php5-fastcgi /cgi-bin/php.fcgi

Order allow,deny

Allow from all

</Directory>

<Directory "/opt/vhost/www.com/cgi-bin">

AllowOverride None

Options None

Order allow,deny

Allow from all

</Directory>

# cp /opt/app/httpd-2.2.9/conf/httpd.conf /opt/app/httpd-2.2.15-fastcgi/conf/ (update all strings from 2.2.9 to 2.2.15-fastcgi)

# cp /opt/app/httpd-2.2.9/conf/extra/httpd-vhost.conf /opt/app/httpd-2.2.15-fastcgi/conf/extra/ (update all strings from 2.2.9 to 2.2.15-fastcgi)

# cp /opt/app/httpd-2.2.9/conf/extra/httpd-modjk.conf /opt/app/httpd-2.2.15-fastcgi/conf/extra/

# cp /opt/app/httpd-2.2.9/conf/extra/httpd-mpm.conf /opt/app/httpd-2.2.15-fastcgi/conf/extra/

# cp /opt/app/httpd-2.2.9/conf/extra/httpd-ssl.conf /opt/app/httpd-2.2.15-fastcgi/conf/extra/ (update all strings from 2.2.9 to 2.2.15-fastcgi)

# cp /opt/app/httpd-2.2.9/conf/extra/*.properties /opt/app/httpd-2.2.15-fastcgi/conf/extra/

# cp -R /opt/app/httpd-2.2.9/conf/ssl.travelzen.com /opt/app/httpd-2.2.15-fastcgi/conf/

Create symbolic link to the libevent-1.4.so.2 in /usr/lib64/

ln -s /opt/app/libevent-1.4.13/lib/libevent-1.4.so.2 /usr/lib64/libevent-1.4.so.2

------------ / -----------

# cat memcached

#!/bin/bash

#

# memcachedThis shell script takes care of starting and stopping

#standalone memcached.

#

# chkconfig: - 80 12

# description: memcached is a high-performance, distributed memory

#object caching system, generic in nature, but

#intended for use in speeding up dynamic web

#applications by alleviating database load.

# processname: memcached

# config: /etc/memcached.conf

# Source function library.

. /etc/rc.d/init.d/functions

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

DAEMON=/opt/app/memcached-1.4.5/bin/memcached

DAEMONBOOTSTRAP=/opt/app/memcached-1.4.5/bin/start-memcached

DAEMONCONF=/opt/app/memcached-1.4.5/conf/memcached.conf

NAME=memcached

DESC=memcached

PIDFILE=/var/run/$NAME.pid

prog=memcached

[ -x $DAEMON ] || exit 0

[ -x $DAEMONBOOTSTRAP ] || exit 0

RETVAL=0

start() {

echo -n $"Starting $DESC: "

daemon $DAEMONBOOTSTRAP $DAEMONCONF

RETVAL=$?

[ $RETVAL -eq 0 ] && touch $PIDFILE

echo

return $RETVAL

}

stop() {

echo -n $"Shutting down $DESC: "

killproc $NAME

RETVAL=$?

echo

[ $RETVAL -eq 0 ] && rm -f $PIDFILE

return $RETVAL

}

# See how we were called.

case "$1" in

start)

start

;;

stop)

stop

;;

restart|reload)

stop

start

RETVAL=$?

;;

status)

status $prog

RETVAL=$?

;;

*)

echo $"Usage: $0 {start|stop|restart|status}"

exit 1

esac

exit $RETVAL

------------- / -------------

# cat start-memcached

#!/usr/bin/perl -w

# start-memcached

# 2003/2004 - Jay Bonci <jaybonci@debian.org>

# This script handles the parsing of the /etc/memcached.conf file

# and was originally created for the Debian distribution.

# Anyone may use this little script under the same terms as

# memcached itself.

use strict;

if ($> != 0 and $< != 0) {

print STDERR "Only root wants to run start-memcached.\n";

exit;

}

my $etcfile = shift || "/opt/app/memcached-1.4.5/conf/memcached.conf";

my $params = [];

my $etchandle;

# This script assumes that memcached is located at /usr/bin/memcached, and

# that the pidfile is writable at /var/run/memcached.pid

my $memcached = "/opt/app/memcached-1.4.5/bin/memcached";

my $pidfile = "/var/run/memcached.pid";

# If we don't get a valid logfile parameter in the /etc/memcached.conf file,

# we'll just throw away all of our in-daemon output. We need to re-tie it so

# that non-bash shells will not hang on logout. Thanks to Michael Renner for

# the tip

my $fd_reopened = "/dev/null";

sub handle_logfile {

my ($logfile) = @_;

$fd_reopened = $logfile;

}

sub reopen_logfile {

my ($logfile) = @_;

open *STDERR, ">>$logfile";

open *STDOUT, ">>$logfile";

open *STDIN, ">>/dev/null";

$fd_reopened = $logfile;

}

# This is set up in place here to support other non -[a-z] directives

my $conf_directives = {

"logfile" => \&handle_logfile

};

if (open $etchandle, $etcfile) {

foreach my $line (<$etchandle>) {

$line =~ s/\#.*//go;

$line = join ' ', split ' ', $line;

next unless $line;

next if $line =~ /^\-[dh]/o;

if ($line =~ /^[^\-]/o) {

my ($directive, $arg) = $line =~ /^(.*?)\s+(.*)/;

$conf_directives->{$directive}->($arg);

next;

}

push @$params, $line;

}

}

unshift @$params, "-u root" unless (grep $_ eq '-u', @$params);

$params = join " ", @$params;

if (-e $pidfile) {

open PIDHANDLE, "$pidfile";

my $localpid = <PIDHANDLE>;

close PIDHANDLE;

chomp $localpid;

if (-d "/proc/$localpid") {

print STDERR "memcached is already running.\n";

exit;

} else {

`rm -f $localpid`;

}

}

my $pid = fork();

if ($pid == 0) {

reopen_logfile($fd_reopened);

exec "$memcached $params";

exit(0);

} elsif (open PIDHANDLE,">$pidfile") {

print PIDHANDLE $pid;

close PIDHANDLE;

} else {

print STDERR "Can't write pidfile to $pidfile.\n";

}

------------ / -----------

# cat memcached.conf

-d

#Memory a usar

-m 64

# default port

-p 11211

# user to run daemon nobody/apache/www-data

-u daemon

# only listen locally

#-l 127.0.0.1

# override slab size

-I 20m

-v

logfile /opt/logs/www.com/memcached_log