I have proved this to be working for me. I hope this is helpful to others
Compiling Lighttpd from source
./configure –prefix=/usr –exec-prefix=/usr –bindir=/usr/bin –sbindir=/usr/sbin –sysconfdir=/etc –datadir=/usr/share –includedir=/usr/include –libdir=/usr/lib –libexecdir=/usr/libexec –localstatedir=/var –sharedstatedir=/usr/com –mandir=/usr/share/man –infodir=/usr/share/info –with-openssl –with-pcre –with-zlib –with-bzip2 –disable-ipv6 –with-PACKAGE=mod_redirect –with-rewrite –with-redirect ./configure –program-prefix= –prefix=/usr –exec-prefix=/usr –bindir=/usr/bin –sbindir=/usr/sbin –sysconfdir=/etc –datadir=/usr/share –includedir=/usr/include –libdir=/usr/lib –libexecdir=/usr/libexec –localstatedir=/var –sharedstatedir=/usr/com –mandir=/usr/share/man –infodir=/usr/share/info –with-openssl –with-pcre –with-zlib –with-bzip2 –disable-ipv6 –with-PACKAGE=mod_redirect –with-rewrite –with-redirect ;
$ make
# make install
Light-httpd-conf
=======
server.document-root = “/var/www/html”
server.port = 80
server.username = “lighttpd”
server.groupname = “lighttpd”
server.bind = “192.168.1.245″
server.tag =”lighttpd”
server.errorlog = “/var/log/lighttpd/error.log”
accesslog.filename = “/var/log/lighttpd/access.log”
server.modules = (
“mod_access”,
“mod_accesslog”,
“mod_fastcgi”,
“mod_rewrite”,
“mod_auth”
)
# mimetype mapping
mimetype.assign = (
“.pdf” => “application/pdf”,
“.sig” => “application/pgp-signature”,
“.spl” => “application/futuresplash”,
“.class” => “application/octet-stream”,
“.ps” => “application/postscript”,
“.torrent” => “application/x-bittorrent”,
“.dvi” => “application/x-dvi”,
“.gz” => “application/x-gzip”,
“.pac” => “application/x-ns-proxy-autoconfig”,
“.swf” => “application/x-shockwave-flash”,
“.tar.gz” => “application/x-tgz”,
“.tgz” => “application/x-tgz”,
“.tar” => “application/x-tar”,
“.zip” => “application/zip”,
“.mp3″ => “audio/mpeg”,
“.m3u” => “audio/x-mpegurl”,
“.wma” => “audio/x-ms-wma”,
“.wax” => “audio/x-ms-wax”,
“.ogg” => “audio/x-wav”,
“.wav” => “audio/x-wav”,
“.gif” => “image/gif”,
“.jpg” => “image/jpeg”,
“.jpeg” => “image/jpeg”,
“.png” => “image/png”,
“.xbm” => “image/x-xbitmap”,
“.xpm” => “image/x-xpixmap”,
“.xwd” => “image/x-xwindowdump”,
“.css” => “text/css”,
“.html” => “text/html”,
“.htm” => “text/html”,
“.js” => “text/javascript”,
“.asc” => “text/plain”,
“.c” => “text/plain”,
“.conf” => “text/plain”,
“.text” => “text/plain”,
“.txt” => “text/plain”,
“.dtd” => “text/xml”,
“.xml” => “text/xml”,
“.mpeg” => “video/mpeg”,
“.mpg” => “video/mpeg”,
“.mov” => “video/quicktime”,
“.qt” => “video/quicktime”,
“.avi” => “video/x-msvideo”,
“.asf” => “video/x-ms-asf”,
“.asx” => “video/x-ms-asf”,
“.wmv” => “video/x-ms-wmv”,
“.bz2″ => “application/x-bzip”,
“.tbz” => “application/x-bzip-compressed-tar”,
“.tar.bz2″ => “application/x-bzip-compressed-tar”
)
index-file.names = ( “index.html”, “index.php” )
=======
mkdir /etc/lighttpd/
groupadd lighttpd
# useradd -g lighttpd -d /var/www/html -s /sbin/nologin lighttpd
mkdir /var/log/lighttpd
# chown lighttpd:lighttpd /var/log/lighttpd
Start Light httpd.
==============================
lighttpd -D -f lighttpd.conf
==============================
Startup script
=====
#!/bin/sh
#
# lighttpd Startup script for the lighttpd server
#
# chkconfig: – 85 15
# description: Lightning fast webserver with light system requirements
#
# processname: lighttpd
# config: /etc/lighttpd/lighttpd.conf
# config: /etc/sysconfig/lighttpd
# pidfile: /var/run/lighttpd.pid
#
# Note: pidfile is assumed to be created
# by lighttpd (config: server.pid-file).
# If not, uncomment ‘pidof’ line.
# Source function library
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/lighttpd ]; then
. /etc/sysconfig/lighttpd
fi
if [ -z "$LIGHTTPD_CONF_PATH" ]; then
LIGHTTPD_CONF_PATH=”/etc/lighttpd/lighttpd.conf”
fi
prog=”lighttpd”
lighttpd=”/usr/sbin/lighttpd”
RETVAL=0
start() {
echo -n $”Starting $prog: ”
daemon $lighttpd -f $LIGHTTPD_CONF_PATH
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
return $RETVAL
}
stop() {
echo -n $”Stopping $prog: ”
killproc $lighttpd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
return $RETVAL
}
reload() {
echo -n $”Reloading $prog: ”
killproc $lighttpd -HUP
RETVAL=$?
echo
return $RETVAL
}
case “$1″ in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
condrestart)
if [ -f /var/lock/subsys/$prog ]; then
stop
start
fi
;;
reload)
reload
;;
status)
status $lighttpd
RETVAL=$?
;;
*)
echo $”Usage: $0 {start|stop|restart|condrestart|reload|status}”
RETVAL=1
esac
exit $RETVAL
=====
Php compilation (commonly used)
=============
./configure –prefix=/usr –with-xml –enable-bcmath –enable-calendar –with-curl –with-swf=/usr/local/flash –enable-ftp –with-gd –with-jpeg-dir=/usr/local –with-png-dir=/usr –with-xpm-dir=/usr/X11R6 –with-gettext –with-imap=/usr/local/imap-2004g –enable-mbstring –enable-mbstr-enc-trans –enable-mbregex –with-mcrypt –with-mhash –enable-magic-quotes –with-mysql=/usr –with-openssl –enable-discard-path –with-pear –with-pspell –enable-sockets –enable-track-vars –with-xmlrpc
–with-zip –with-zlib –prefix=/usr/local/php5 –exec-prefix=/usr/local/php5 –program-suffix=5 –enable-force-cgi-redirect –enable-discard-path
==============
For compiling PHP, we will need quite a few external libraries, like libcurl, libiconv, libjpeg, libpng, and few others, which we have to download and compile first:
* PHP 5.0.3 itself – php-5.0.3.tar.bz2
* CURL library – curl-7.12.1.tar.gz
* libiconv library – libiconv-1.9.2.tar.gz
* JPEG library: jpegsrc.v6b.tar.gz
* PNG library: libpng-1.2.8.tar.gz
* cpdflib library: clibpdf202r1.tar.gz
* Freetype 2 library: freetype-2.1.9.tar.bz2
Compile libiconv from source:
cd /usr/local/src
tar -zxvf libiconv-1.9.2.tar.gz
cd libiconv-1.9.2
./configure –prefix=/usr/local
make
make install
Compile libjpeg from source:
cd /usr/local/src
tar -zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
./configure –prefix=/usr/local
make
make install
make install-lib
Compile libpng from source:
cd /usr/local/src
tar -zxvf libpng-1.2.8.tar.gz
cd libpng-1.2.8
cp scripts/makefile.linux makefile
make
make install
Compile cpdflib from source:
cd /usr/local/src
tar -zxvf clibpdf202r1.tar.gz
cd ClibPDF/source
cp Makefile.Linux makefile
make
make install
Compile curl from source:
cd /usr/local/src
tar -zxvf curl-7.12.1.tar.gz
cd curl-7.12.1
./configure –prefix=/usr/local
make
make install
Compile freetype 2 from source:
cd /usr/local/src
tar -jxvf freetype-2.1.9.tar.bz2
cd freetype-2.1.9
./configure –prefix=/usr/local
make
make install
Next, we will compile PHP, with support for MySQL, iconv, curl, zlib, gd2, mbstring, SSL and many other modules:
For best results use the following options for compiling php as cli with apache.
=============
cd /usr/local/src
tar -jxvf php-5.0.3.tar.bz2
cd php-5.0.3
./configure \
–with-apxs2=/usr/local/apache2/bin/apxs \
–with-mysql=/usr/local/mysql \
–with-mysqli=/usr/local/mysql/bin/mysql_config \
–with-mysql-sock=/tmp/mysql.sock \
–with-sqlite \
–enable-sqlite-utf8 \
–with-zlib \
–with-zlib-dir \
–with-bz2 \
–with-gd \
–enable-gd \
–enable-gd-native-ttf \
–with-jpeg-dir=/usr/local \
–with-png-dir=/usr/local \
–with-ttf \
–with-freetype-dir=/usr/local \
–with-iconv=/usr/local \
–with-curl=/usr/local \
–enable-track-vars \
–with-gettext \
–with-config-file-path=/usr/local/apache2/conf \
–enable-trans-id \
–enable-ftp \
–with-cpdflib=/usr/local \
–enable-mbstring \
–with-openssl=/usr/local
make
make install
cp php.ini-dist /usr/local/apache2/conf/php.ini
Next, we have to modify PHP configuration in file /usr/local/apache2/conf/php.ini, including basic PHP security settings:
mysql.default_socket = /tmp/mysql.sock
short_open_tag = Off
register_globals = Off
allow_url_fopen = Off
=============
Install php with Lighttpd as fastcgi (basic)
./configure –enable-fastcgi –prefix=/usr/local/php/ ‘–with-mysql=/usr/local/mysql \
Install php with Lighttpd as fastcgi (all modules supported)
===============
./configure –enable-fastcgi –prefix=/usr/local/php/ –with-mysql=/usr/local/mysql \ –with-mysqli=/usr/local/mysql/bin/mysql_config –with-mysql-sock=/tmp/mysql.sock –with-sqlite –enable-sqlite-utf8 –with-zlib –with-zlib-dir –with-bz2 –with-gd –enable-gd –enable-gd-native-ttf –with-png-dir=/usr/local –with-ttf –with-freetype-dir=/usr/local –with-iconv=/usr/local –enable-track-vars –with-gettext –with-config-file-path=/usr/local/apache2/conf –enable-trans-id –enable-ftp –enable-mbstring –with-jpeg-dir=/usr/local \ ;
===============
Configuring PHP
=======================================
cp php.ini-dist /usr/local/lib/php.ini
=======================================
If you want to use PATH_INFO and PHP_SELF in you PHP scripts you have to configure php and lighttpd. The php.ini needs the option:
=====================
cgi.fix_pathinfo = 1
=====================
Now start light httpd with info.php
====
<?php phpinfo() ?>
====
Core Light Httpd directives
=========
* server.document-root = “/var/www/html”: Specifies default document-root for your server.
* server.port = 80: Specifies default http port for your server.
* server.username = “lighttpd”
* server.groupname = “lighttpd”: Specifies default username and groups to start/stop lighttpd server. This is a security feature (as it drops root privileges).
* server.bind = “server-ip-address”: Specify server ip-address. You can also specify hostname such as theos.in.
* server.tag =”lighttpd”: Use to setup lighttpd name and version number (default). This is security feature. You can setup it as follows:
server.tag =”myWebServer v1.0″
Please note that this name is reported by the Server response header (you can see it using netcraft)
* server.errorlog = “/var/log/lighttpd/error.log”: Specify the error-log file.
* accesslog.filename = “/var/log/lighttpd”: Specify the accesslog file name (use to generate stats using stats software).
* index-file.names = ( “index.php”, “index.html” ): A list of files to search for if a directory is requested.
server.modules = (
“mod_access”,
“mod_accesslog”,
“mod_fastcgi”,
“mod_rewrite”,
“mod_auth”
): Above modules are loaded by lighty:
* mod_access: The access module is used to deny access to files with given trailing path names.
* mod_accesslog: Use to write CLF log, flexible like apache
* mod_fastcgi : FastCGI for perl/PHP etc
* mod_rewrite : Good for writing SEO urls
* mod_auth: Authntication (password protected directory)
mimetype.assign = (
“.pdf” => “application/pdf”,
“.sig” => “application/pgp-signature”
): Use to setup mimetype mapping.
=========