How to Install Lighttpd with PHP-FPM on CentOS 7

Lighttpd is a lightweight, free and open source, fast and secure web server. Compared to other web servers such as Apache and Nginx, Lighttpd goes easy on memory utilization and is optimized for high performance. It’s an ideal web server for Ruby on Rails frameworks and popular with high traffic websites such as Wikimedia.

The web server supports quite many advanced features including:

  • IPv4 and IPv6
  • Support for SCGI HTTP Proxy as well as FastCGI used for load balancing
  • HTTP compression with mod_deflate
  • Support for Chroot that alters the root directory for running processes and their children
  • setGID , setUID
  • TLS/SSL with SNI support, via OpenSSL
  • Authentication with an LDAP server.
  • URL rewriting

In this article, we’ll dive deep and see how you can install Lighttpd with PHP-FPM on a CentOS 7 server.

Installation of Lighttpd

To install Lighttpd, you need to log in as root user. Lighttpd can be installed from source or available packages. But first, you need to update the system

yum update -y

Ensure that there are no web servers currently running on your server system like Apache or Nginx running. If you had already installed any of them, remove them using the command below.

yum -y erase httpd nginx

Since lighttpd is not available on CentOS default repositories, you need to install EPEL (Extra packages for Enterprise Linux)

yum -y install epel-release

Afterwards, update the system

yum -y update

Next, install lighttpd using the command below

yum -y install lighttpd

After the installation of lighttpd is done, start the service.

systemctl start lighttpd

Enable it to start on boot time

systemctl enable lighttpd

To verify the version of lighttpd installed on your system run,

lighttpd -v


lighttpd/1.4.49 (ssl) - a light and fast webserver

Adjust firewall rules to allow http and https traffic

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https

Reload the firewall for the changes to take effect

firewall-cmd --reload

Open up your browser and go to your server’s url

http://localhost/ or http://serveripaddress/

install Lighttpd


If you type in your server IPv4 address in the URL bar, you’ll get an error.

This is because on line 98 of the /etc/lighttpd/lighttpd.conf  file, ‘server.bind’ is given ‘localhost’ attribute as seen below.


Install Lighttpd with PHP-FPM

Replace’localhost’ with your server’s IPv4 address.

Install Lighttpd with PHP-FPM

Save the changes and exit.

Restart Lighttpd service

systemctl restart lighttpd

Go to your web browser


Install Lighttpd with PHP-FPM

The browser will load default page for Lighttpd.

Installing PHP-FPM

Since most websites are developed using php, you may be required to have php working alongside your Lighttpd server. PHP can be installed using PHP-FPM short for FastCGI process Manager. This has additional features, especially for high traffic sites.

To install php-fpm run,

yum -y install php-fpm lighttpd-fastcgi

Next, using your favorite text editor edit /etc/php-fpm.d/www.conf to configure PHP-FPM to run as a FastCGI server on port 9000.

vim /etc/php-fpm.d/www.conf

On lines 39 and 41,  the value of user and group  is ‘apache’
Install Lighttpd with FPM-PHP

Replace apache with lighttpd as shown below

Install Lighttpd with PHP-FPM

Save the changes and exit

Start the PHP_FPM service

systemctl start php-fpm

Enable the service on boot

systemctl enable php-fpm

Configuring Lighttpd to Work With PHP

For PHP to work alongside Lighttpd server, a few changes have to be made in the /etc/php.ini file.

Open the file using your favorite text editor

vim /etc/php.ini

Uncomment line 763 so that we end up with



Install Lighttpd with PHP-FPMSave the changes and exit.

Afterwards, open /etc/lighttpd/conf.d/fastcgi.conf with the editor of your choice

vim /etc/lighttpd/conf.d/fastcgi.conf

Locate line 8

server.modules += ( "mod_fastcgi" )

and add the following lines of code beneath it.

fastcgi.server += ( ".php" =>
"host" => "",
"port" => "9000",
"broken-scriptfilename" => "enable"

Save the changes and exit.

Next open /etc/lighttpd/modules.conf

vim /etc/lighttpd/modules.conf

Locate #include "conf.d/fastcgi.conf" on line 138 and uncomment it so that we end up with

include "conf.d/fastcgi.conf"

Install Lighttpd with PHP-FPM

Save the changes and exit.

Restart both php-fpm and lighttpd

systemctl restart php-fpm && systemctl restart lighttpd

To ensure that our lihgttpd server is set to use php-fpm, create an info.php file in /var/www/lighttpd

vim /var/www/lighttpd/info.php

Add the following line

phpinfo (); 

Restart the Lighttpd service

systemctl restart lighttpd

Open your web browser and go to the url below


Wrapping up

In this article, we have successfully managed to install Lighttpd which handle a high volume of concurrent web traffic, PHP-FPM and managed to integrate the two. Feel free to proceed and install MySQL or Maria DB database. You are welcome to try out the commands and give us feedback. Thank you.

Installation and securing of Memcached on CentOS 7
Install and Configure Pagespeed on Nginx on CentOS 7


Canadian Web Hosting Service Provider, Domain Names, Canadian Network, Canadian Servers and Canadian IP Address.

Leave a Reply

Notify of