Download the latest source from lighttpd.net

$wget -O http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.29.tar.gz /usr/src/lighttpd.tar.gz<br></br>
$cd /usr/src<br></br>
$tar -zxvf lighttpd.tar.gz<br></br>
$cd lighttpd```

**Now Configure lighttpd:**  

$ ./configure --host=i686-redhat-linux-gnu --build=i686-redhat-linux-gnu --target=i386-redhat-linux <br>

--program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin <br>

--sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec <br>

--localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info <br>

--with-openssl --with-pcre --with-zlib --with-bzip2 --disable-ipv6 --with-PACKAGE=mod_redirect <br>

--with-rewrite --with-redirect --with-ssi```

**
Now Compile and Install:**

$make && make install

Now make configuration Directory for lighttpd:
#mkdir /etc/lighttpd

Create user and group:

#groupadd lighttpd<br></br>
#useradd -g lighttpd -d /var/www/html -s /sbin/nologin lighttpd```

**Create directory for logfiles:**  

mkdir /var/log/lighttpd

chown lighttpd:lighttpd /var/log/lighttpd```

Create a sample config file :

#vi /etc/lighttpd/lighttpd.conf

Paste the following Sample with php support:

server.document-root = "/var/www/html"

server.port = 80
server.username = "lighttpd"
server.groupname = "lighttpd"
server.bind = "0.0.0.0"
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"
)

This is for php support

fastcgi.server = ( ".php" => ((
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/tmp/php.socket"
))
)

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" )

Now Create the init script:

vi /etc/init.d/lighttpd

paste the following:

#!/bin/sh<br></br>
#<br></br>
# lighttpd     Startup script for the lighttpd server<br></br>
#<br></br>
# chkconfig: - 85 15<br></br>
# description: Lightning fast webserver with light system requirements<br></br>
#<br></br>
# processname: lighttpd<br></br>
# config: /etc/lighttpd/lighttpd.conf<br></br>
# config: /etc/sysconfig/lighttpd<br></br>
# pidfile: /var/run/lighttpd.pid<br></br>
#<br></br>
# Note: pidfile is assumed to be created<br></br>
# by lighttpd (config: server.pid-file).<br></br>
# 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

**Now make the init script executable:**

`#chmod +x /etc/init.d/lighttpd`