How To Install Linux, Lighttpd, MySQL,


Lighttpd is an open source web server originally written by Jan Kneschke as an alternative to Apache, it has a low memory footprint and numerous websites such as YouTube and Wikimedia run Lighttpd servers. MySQL is a popular database solution for use in web applications (such as WordPress) and is generally combined with a server side scripting language, PHP.

This tutorial will show you the steps required to install Lighttpd, PHP and MySQL on CentOs 6 so that you can get up and running with your Server.

Step One – Prerequisites

Update your system:

sudo yum update

You will need to install wget, a package for retrieving files using HTTP, HTTPS and FTP:

sudo yum install wget

Notice that the command starts with “sudo”. This will allow you to run the instructions with root privileges.

Step Two – Installing MySQL

To install MySQL, login into your VPS and type:

sudo yum install mysql-server

Create a system start-up link for MySQL to enable the services to run at boot:

sudo chkconfig --levels 235 mysqld on

This might seem silly, but it is a good idea to verify that the MySQL server is running, otherwise you will come up with a MySQL ERROR 2002 (HY000) when executing the mysql_secure_installation command:

sudo service mysqld status

If the VPS is not running type:

sudo service mysqld start

Create a password for the MySQL user root and perform some initial configurations:

sudo mysql_secure_installation
Enter current password for root (enter for none):_

Since a MySQL root password has not been configured we can just press ENTER and continue with the process of setting up MySQL:

Set root password? [Y/n] y
Re-enter new password: SQL.ROOT.PASSWORD.EXAMPLE
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y

Step Three – Installing Lighttpd

Lighttpd and PHP-FPM are not supported from the official CentOS repositories, let’s go ahead and add the Remi RPM and the EPEL repositories to CentOS:

sudo rpm --import https://fedoraproject.org/static/0608B895.txt
sudo wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm -ivh epel-release-6-8.noarch.rpm

Then run the following command to install Lighttpd:

sudo yum install lighttpd

Create a system start-up link for Lighttpd to enable the service to run at boot:

sudo chkconfig --levels 235 lighttpd on

Start the service and check that it is running:

sudo service lighttpd start
sudo service lighttpd status

Open your browser and type your VPS’ IP http://123.456.789.10, you can run the following command to reveal your VPS’ IP address:


The Lighttpd welcome page should be displayed:

Typical Errors – Lighttpd Troubleshooting

ERROR 1: Lighttpd fails to start: “socket failed: Address family not supported by protocol” or“please use server.use-ipv6 only for hostnames, not without server.bind…” , open Lighttpd.conf:

sudo nano /etc/lighttpd/lighttpd.conf

And disable IPv6:

server.use-ipv6 = "disable"

ERROR 2: Warning “can’t have more connections than fds/2: 1024 1024”, open Lighttpd.conf:

sudo nano /etc/lighttpd/lighttpd.conf

Uncomment #server.max-fds = 2048:

server.max-fds = 2048

Restart Lighttpd:

sudo service lighttpd restart
Stopping lighttpd [OK]
Starting lighttpd [OK]

Step Four – Installing PHP

Install PHP5 (FPM):

sudo yum install php-fpm lighttpd-fastcgi

Open www.conf:

sudo nano /etc/php-fpm.d/www.conf

Add lighttpd to the user and group:

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
user = lighttpd
; RPM: Keep a group allowed to write in log dir.
group = lighttpd

Create a system start-up link for PHP-FPM to enable the service to run at boot:

sudo chkconfig --levels 235 php-fpm on

Start the service and check that it is running:

sudo service php-fpm start
sudo service php-fpm status

Once the installation is complete, we have to enable PHP5 in Lighttpd. Let’s find your php.ini file:

sudo nano /etc/php.ini

And uncomment the required line:


Open fastcgi.conf:

sudo nano /etc/lighttpd/modules.conf

And uncomment this line:

include "conf.d/fastcgi.conf"

Open fastcgi.conf

sudo nano /etc/lighttpd/conf.d/fastcgi.conf

and add the following lines:

## for the php-num-procs example it means you will get 17*5 = 85 php
## processes. you always should need this high number for your very
## busy sites. And if you have a lot of RAM. :)
fastcgi.server += ( ".php" =>
                "host" => "",
                "port" => "9000",
                "broken-scriptfilename" => "enable"
#fastcgi.server = ( ".php" =>

Install MySQL PHP module:

sudo yum install php-mysql

Restart Lighttpd and PHP-FPM:

sudo service php-fpm restart
sudo service lighttpd restart

Step Six (Optional) – Testing PHP using info.php

Create info.php:

sudo nano /var/www/lighttpd/info.php

Add the following lines:


Open your browser and go to your server’s IP http://123.456.789.10/info.php .We can see that PHP is working through FPM/FastCGI:

And that the MySQL module is listed, therefore working:

And that is all; congratulations!


Leave a Reply

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