Recommended VPS Complete list of best VPS hosting providers.

How To Build Working CentOS Server with LightTPD and PHP5 (Part 1)

How to install LightTPD, PHP5 and MySQL on CentOS server. In this guide I will use newest release version, CentOS 6.4 running on my droplet hosted in DigitalOcean’s network. For your information, CentOS 6.4 has been released back in 2013-03-09. Lighttpd is a free asynchronous web server with fast and sleek performance. It is much more faster than Apache. Shortly, it is similar to Nginx and Lighttpd is also the best rival to Nginx.

About Lighttpd (shortly)

lighttpd (pronounced “lighty”)[ is an open-source web server more optimized for speed-critical environments than common products while remaining standards-compliant, secure and flexible. It was originally written by Jan Kneschke as a proof-of-concept of the c10k problem – how to handle 10,000 connections in parallel on one server,but has gained worldwide popularity (WikiPedia).

Most Web 2.0 websites are using Lighty to serve millions users a day, including WikiPedia and YouTube (before acquired by Google).

This tutorial is provided as it as. I write it purely for educational and learning purpose. I don’t recommend you to use Lighttpd on production server if you don’t know more about it. Again, my purpose writing this tutorial is to guide you how to install Lighttpd on CentOS so you can know it, learn it so you will be able to learn more about it (if you want).

Honestly, personally, I still prefer Nginx than Lighttpd. Anyway, read on..


  1. A working CentOS server. In this guide I am using CentOS 6.4 x86.
  2. Windows users should download Putty while Mac and Linux users can simply use Terminal
  3. You’ll also need a basic skill to use Putty and to navigate through SSH. Read: Most common Unix commands used to SSH.
  4. About 15 minutes of your time and a cup of coffee if you like.

How to install Lighttpd on CentOS

Step 1 – Login to your server and follow my previous guide about Basic setup for CentOS before you build a live web server. You may and may not follow that tutorial but if you followed, it will give you some basic security tweak to your server.

Before you proceed to the next steps, it is better to explain that all commands in this tutorial are written without the “sudo” prefix. However if you disabled root login and you logged in using another username with root privilege, you can add the “sudo” prefix all by your self. Alternatively you can simply type su, hit Enter and type in your password twice to switch login as root.

You may also need to type this command to go to the root directory:

cd ~

switch to root

Step 2 – You have to firstly enable the Remi RPM repository plus the EPEL repository because Lighttpd and PHP-FPM are not available from the official CentOS repositories. In this case simply issue following commands:

rpm --import
rpm -ivh epel-release-6-8.noarch.rpm

It will look like this:

add repo

There are other commands you have to issue:

rpm --import
rpm -ivh

It looks like this at my end:

add repo

Finally, execute this command syntax:

yum install yum-priorities

yum install

You it asks you to confirm, simply answer yes or type Y then hit Enter. You’ll get the “Complete!” message indicating the process to add new repo is success.

add repo success

Step 3 – You have to also edit /etc/yum.repos.d/epel.repo file. Use Nano for that:

nano /etc/yum.repos.d/epel.repo

In the top part of the screen you’ll see the [epel] section. Add priority=10 line in it. See the screenshot below:

add priority

Once done, hit Control+O to save then Control+X to exit.

Step 4 – You have to also edit /etc/yum.repos.d/remi.repo file. Use Nano for that:

nano /etc/yum.repos.d/remi.repo

In the top part of the screen you’ll see the [remi] section. Add priority=10 line in it and change enabled to 1. See the screenshot below:

add remi priority

Hit Control+O to save it then Control+X to exit.

Step 5 – It’s time to install Lighttpd. The command syntax is simple:

yum install lighttpd

install lighttpd

Hit Y if asked.

Step 6 – Optional but recommended: Add system startup links for Lighttpd service so it starts automatically whenever the system boots. Use this command:

chkconfig --levels 235 lighttpd on

Step 7 – In this point you can now start Lightpd service:

/etc/init.d/lighttpd start


service lighttpd start

Note: The service may start with following error:

(network.c260) warning: please use server. use-ipv6 only for hostnames, not without server.bind / empty address; your config will break if the kernel default for IPV6_V6ONLY changes.


(network.c.203) socket failed: Address family not supported by protocol

You can fix by by editing lighttpd.conf file:

nano /etc/lighttpd/lighttpd.conf

Find the Basic Configuration section and find server.use-ipv6, change its value to “disable”.

disable ipv6

Save it and exit.

Note 2: You may also get following error:

(server.c.915) can't have more connections than fds/2: 1024 1024

You can fix it, again, by editing lighttpd.conf file:

nano /etc/lighttpd/lighttpd.conf

Find the line that says “#server.max-fds = 2048“. Found it? Now remove the # symbol (uncomment it):


Save it and exit. Now you should not see any error again:


Test it in your browser by typing your server’s IP and you should see this:

lighttpd success ok

Next, installing PHP5-fpm and MySQL on your CentOS server with Lighttpd already installed and running on it. I’ll write about it ASAP as Part 2 of this tutorial.

Index of this guide: Part 1Part 2Part 3Part 4.

Next Part 2:

How to Install MySQL5 on CentOS with Lighttpd Web Server.


Add a Comment

Your email address will not be published. Required fields are marked *

Get more stuff like this
in your inbox

Subscribe and get interesting stuff plus faster updates to your email.