Lighttpd + PHP5 and MySQL on Debian Squeeze (Part 1): Lighttpd

This three part guide will help you install the lighttpd web server along with PHP5 and MySQL support.


Installing and configuring the Lighttpd web server:


Use the Debian aptitude/apt-get command to install lighttpd:

# aptitude install lighttpd


**skip to the configuration section 


Install from source:

*You can choose to use the release/snapshot from the lighttpd or compile from SVN:


1. Extract the tar

                # tar -xf lighttpd-1.4.XXX.tar.gz

2.  Enter the new directory:

           # cd lighttpd-1.4.XXX
  •  Compile from SVN:
  # svn checkout svn://
  # ./
  # svn update
  # ./

Build dependencies

 #aptitude build-dep lighttpd
 # ./configure
 # make

# su make install

Init script 

sed -e 's/FOO/lighttpd/g' doc/initscripts/rc.lighttpd > /etc/init.d/lighttpd
chmod a+rx /etc/init.d/lighttpd
cp -p doc/initscripts/sysconfig.lighttpd /etc/sysconfig/lighttpd
mkdir -p /etc/lighttpd

# < 1.4.27
install -Dp ./doc/lighttpd.conf /etc/lighttpd/lighttpd.conf

# > 1.4.28
cp -R doc/config/conf.d/ doc/config/*.conf doc/config/vhosts.d/ /etc/lighttpd/

chkconfig lighttpd on


Configuring Lighttpd

*further reading on lighttpd.conf


The lighttpd configuration file is located at /etc/lighttpd/lighttpd.conf


Sample lighttpd.conf


# vi /etc/lighttpd/lighttpd.conf
  • Make the appropriate changes to the lighttpd server directives (i.e. server.upload-dirs/server.document-root)
  • Check that your configuration is working:
#lighttpd -t -f /etc/lighttpd/lighttpd.conf
#lighttpd -D -f /etc/lighttpd/lighttpd.conf

If all goes well you should see the message "Syntax OK"

  • Save and exit out of the file (if you are using vim: !Esc followed by :wq)
  • Start the lighttpd service:
# /etc/init.d/lighttpd start
  • Make sure that the service is running:
# /etc/init.d/lighttpd status OR
# netstat -ntulp


Remove apache2 web server:


Make sure apache2 has stopped:

             # /etc/init.d/apache2/stop

Remove apache2:

# aptitude purge apache2 apache2-utils apache2.2-bin apache2-common
# aptitude autoremove



For troubleshooting, check the lighttpd wiki or the support forum


Part 2: Lighttpd + PHP5 and MySQL on Debian Squeeze (Part 2): PHP5


Further readings: 




Leave a Reply