How to Install Lighttpd With PHP

lighttpdIn this small tutorial , we are going to install lighttpd with PHP support on a CentOS VPS. Lighttpd is a webserver like Apache and is reputed to be a fast web server. Here are the step by step instruction ( You will need to be logged in as Root in your VPS to perform all these commands) :

Step One: First we need to add necessary repositories so that we can install lighttpd using these repos.

For CentOS 32 bit use the following command:

rpm -Uhv

and for adding repos for 64 bit version of CentOS , use the following command :

rpm -Uhv

Step Two: After adding the necessary repositories , we are going to install lighttpd now with YUM

yum install lighttpd

Step Three: Once this command completes successfully, we will install PHP as well with this command:

yum install lighttpd-fastcgi php-cli

Step Four: Our next step is to configure lighttpd by doing the following :

nano /etc/lighttpd/lighttpd.conf

The file will open for editing . Search the file and set

server.use-ipv6 = "disable"

Step Five: Next we edit the /etc/lighttpd/modules.conf file by using Nano editor

nano /etc/lighttpd/modules.conf

Once the file opens for editing , find the server.modules stanza and uncomment all of its lines by removing # sign from these lines. The new file after uncommenting should look like this:

server.modules = (

Move further down in the file and uncomment the following line as well:

#include “conf.d/fastcgi.conf”

The edited file should look like this:

## FastCGI (mod_fastcgi)
include "conf.d/fastcgi.conf"

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

Now put some index.html file in /srv/www/lighttpd directory because otherwise lighttpd will throw out an error.  In order to see that both lighttpd and PHP have been installed, create an info.php file like this and place it in /srv/www/lighttpd .


Now type http://ServerIP/info.php  in your browser and you should be able to see PHP info page processed by lighttpd web server. ServerIP here is the IP address of your VPS.



Leave a Reply