How to Install LLMP Stack on CentOS 6

Lighttpd is an open source web server designed for high performance environments. Several web 2.0 sites have been powered by lighttpd.

LLMP stack refers to Linux, Lighttpd, MySQL and PHP. This tutorial will cover the basics of installing LLMP stack on CentOS 6.


System Prerequisites


This tutorial will use CentOS 6. You should make sure you already have done the initial server set up. Also, we will need user with root privileges. Refer to this tutorial for getting them done.

Once you are done with the server set up, we will proceed to updating the system:

sudo yum update

Since we are using the sudo option to run the commands, it will execute with root privileges.

Next step is to install the wget package which is used for retrieving files using HTTP, HTTPS and FTP:

sudo yum install wget

Installation of MySQL


For installing MySQL, log into your VPS and type in the command:

sudo yum install mysql-server

You have to create a system start-up link for MySQL so that the services will be run at the time of booting.

sudo chkconfig --levels 235 mysqld on

At this point, you may have a quick check on the status of MySQL server to ensure its up and running. This step will save you time later on in case if you get a mysql error 2002 while running the secure installation script.

sudo service mysqld status

In case if VPS is not running, type in:

sudo service mysqld start

Now, let’s move on with the configuration changes.

Run the secure install script. While the secure install scrip is running, the system will ask for your MySQL root password. In that case, just hit enter and continue with the process.

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

Since the mysql root password has not been set already, it’s okay to leave it empty. After that, the system will prompt a few more questions. It’s recommended that you give yes for those questions dealing with removing test databases, users and privileges for users.

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


Installing Lighttpd


Since Lighttpd is not supported by CentOS repositories, we will have to add certain packages before installing. PHP-FPM as well is not supported. So, we will be adding Remi RPM and EPEL repositories to CentOS.

sudo rpm --import

sudo wget rpm -ivh epel-release-6-8.noarch.rpm

Now, we can run the Lighttpd install command:

sudo yum install lighttpd

As done in the previous step, here also we will be creating a start-up link for lighttpd to enable the service to run at boot time.

sudo chkconfig --levels 235 lighttpd on


Start the lighttpd and check the status to verify if it’s running:

sudo service lighttpd start
sudo service lighttpd status

You can verify further by pointing your browser to your VPS IP address. Use the command ifconfig to view the IP.


You will see the Lighttpd welcome page like this:



Troubleshooting Lighttpd


Here we will discuss about few common errors for lighttpd:

  1. “socket failed: Address family not supported by protocol”  OR “please use server.use-ipv6 only for hostnames, not without server.bind…”

When lighttpd fails throwing this error, proceed with the following steps:

Open up lighttpd.conf file.

sudo nano /etc/lighttpd/lighttpd.conf

Disable the IPv6:

server.use-ipv6 = "disable"
  1. “can’t have more connections than fds/2: 1024 1024″

In this case, open the config file and uncomment server.max-fds:

sudo nano /etc/lighttpd/lighttpd.conf
server.max-fds = 2048

After making the changes, you will have to restart lighttpd:

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


Installation of PHP


Start with the installation of php-fpm.

sudo yum install php-fpm lighttpd-fastcgi

Now, open the conf and add lighttpd to the user and group:

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


; 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


Again, create a start up link for PHP-FPM to enable service to run at the time of booting:

sudo chkconfig --levels 235 php-fpm on

Verify the status:

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

After that, we need to enable php5 in lighttpd.

Open up the php.ini file and uncomment the given line:

sudo nano /etc/php.ini

Open the /etc/lighttpd/modules.conf and uncomment the given line:

sudo nano /etc/lighttpd/modules.conf
include "conf.d/fastcgi.conf"

Open the fastcgi.conf and add the following:

sudo nano /etc/lighttpd/conf.d/fastcgi.conf
## 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" =>

Now, let’s go ahead and install the MySQL PHP module:

sudo yum install php-mysql

Restart the lighttpd and PHP-FPM:

sudo service php-fpm restart
sudo service lighttpd restart

Now that we are done the changes, we can test it out by creating a php file and calling function phpinfo().

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

Open up the browser and give your server’s IP address. You can confirm that the PHP FPM/FastCGI is working fine. You will be able to see the mysql modules listed. And that’s the end of LLMP installation.


support2 has written 111 articles

Leave a Reply