Installing Lighttpd with PHP-FPM and Mysql on CentOS 7

How to install Lighttpd with PHP-FPM and Mysql on CentOS 7.3

Lighttpd? Lets see about it : lighttpd  a web server for Linux and Windows operating systems, also an alternative to Apache web server. It is also called Lighty. It is designed to be secure, fast, standards-compliant, and flexible while being optimized for speed-critical environments.

lighttpd supports the FastCGI, SCGI and CGI interfaces to external programs, allowing web applications written in any programming language to be used within the server,particularly popular language, PHP performance has received special attention. Lighttpd’s FastCGI can be configured to support PHP with opcode caches (like APC) properly and efficiently. Additionally, it has received attention from its popularity within the Python, Perl, Ruby and Lua communities. Lighttpd also supports WebDNA, the resilient in-memory database system designed to build database-driven websites. It is a popular web server for the Catalyst and Ruby on Rails web frameworks.

1.Prerequisites for installing

  • CentOS 7.
  • root privileges.

Lets see the installing process, by steps.

2.Installing Mysql

For installing and configuring Mysql refer Step No.3 at the below link

Monitoring your Server using Cacti

3.Installing Lighttpd

Basically, Lighttpd and PHP-FPM are not available from the official CentOS repositories, so we should enable the EPEL repository

#yum -y install epel-release

Now, Importing the EPEL GPG-key and update

# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
# yum update

Let, install Lighttpd now.

#yum -y install lighttpd

Create the system startup links for Lighttpd (so that Lighttpd starts automatically whenever the system boots) and start it

#systemctl enable  lighttpd.service
#systemctl start  lighttpd.service

In some cases, if Lighttpd fails to start with the following error message.

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

Open Lighttpd configuration file and modify accordingly

#nano /etc/lighttpd/lighttpd.conf

Here, change server.use-ipv6 from enable to disable:

## Use IPv6?
server.use-ipv6 = "disable"

Now, try to start Lighttpd again – it should now work without any problem:

#systemctl start  lighttpd.service

Now direct your browser to http://server_ip_address/, and you should see the following page:

Lighttpd with PHP-FPM


Note : Lighttpd’s default document root is /var/www/lighttpd/ on CentOS 7, and the configuration file is /etc/lighttpd/lighttpd.conf.

Comment here