Installing lighttpd and PHP 5 with FastCGI on CentOS 5 x86_64

Install PHP

Remove PHP first

rpm -e php php-devel php-imap php-ldap php-pear
Get CentOS PHP src RPM;

Install deps

yum install curl-devel.x86_64 db4-devel.x86_64 expat-devel.x86_64 gmp-devel.x86_64 httpd-devel.x86_64 pam-devel.x86_64 libstdc++-devel.x86_64 libtool.x86_64 gcc-c++.x86_64 ncurses-devel.x86_64 gd-devel.x86_64
yum install aspell-devel.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 libc-client-devel.x86_64 mysql-devel.x86_64 postgresql-devel.x86_64 unixODBC-devel.x86_64 net-snmp-devel.x86_64 elfutils-devel.x86_64 libxslt-devel.x86_64 freetype-devel.x86_64


rpm -ivh php-5.1.6-15.el5.src.rpm
cd /usr/src/redhat/SPECS/

Edit php.spec;

Find --enable-force-cgi-redirect

Before this line add

Build RPM

rpmbuild -bb php.spec

cd /usr/src/redhat/RPMS/x86_64
rpm -ivh php*

Install lighttpd



Install deps

yum install pcre-devel mysql-devel lua lua-devel

Install the lighttpd rpm source file:
rpm -Uvh lighttpd-1.4.16-1.el5.src.rpm
The spec file for lighttpd will be saved into /usr/src/redhat/SPECS

Compile the spec file:
rpmbuild -bb /usr/src/redhat/SPECS/lighttpd.spec
The rpm for lighttpd will be saved into /usr/src/redhat/RPMS/x86_64.

Install lighttpd:
rpm -Uvh /usr/src/redhat/RPMS/x86_64/lighttpd-1.4.16-1.x86_64.rpm

Check whether your lighttpd has been installed:
rpm -qa | grep lighttpd