How to Install Lighttpd with PHP5 (PHP-FPM) and MySQL Support on CentOS 6.3

Lighttpd is specifically created for speed critical environment to provide quick, protected and standards-compliant web browsing. The guide below is to help you install Lighttpd on a Centos 6.3 server with the help of PHP5 and MySQL.

PHP-FPM (FastCGI Process Manager) is another option of PHP FastCGI implementation that gives you some more choices that are quite useful for sites of any size, particularly for those which have comparatively high traffic.

In this guide, we will use PHP-FPM as a substitute of Lighttpd’s spawn fcgi. Further the hostname that is used as, and the IP address that is used as are samples and you need to use your own server names and IPs.


  • 1

    How to Install MySQL 5

    In order to install MySQL 5, follow the procedure given below;

    yum install mysql mysql-server

    After the installation of MySQL 5, make the system startup links for MySQL – it will automatically initiate MySQL every time the system boots – and start the MySQL server:

    chkconfig --levels 235 mysqld on

    /etc/init.d/mysqld start

    Now create passwords for the MySQL root account.


    Current password is required for the root user to log into MySQL to make it protected. If you are unable to set the root password up till now, so you need to press enter here.

    Write current password for root:

    OK, now you can easily use password, moving on...

    By creating the root password helps you to ensure that nobody can misuse MySQL without your permission.

    Set root password? [Y/n] <-- ENTER

    New password: <-- yourrootsqlpassword

    Re-enter new password: <-- yourrootsqlpassword

    Password updated successfully!

    Reloading privilege tables..

    ... Success!

    There is a built in anonymous user in MySQL installation, which authorize anyone to log into MySQL even he/she does not has a user account. This is because for testing purpose only, and to make the installation a bit easier for the user. You have the authority to delete it before going into a production environment.

    Remove anonymous users? [Y/n] <-- ENTER

    ... Success!

    In normal circumstances, you can only connect from ‘localhost’ via root. This makes sure that no one can easily assume at the root password from the network.

    Disallow root login remotely? [Y/n] <-- ENTER

    ... Success!

    MySQL originally comes with a database, having a title name ‘test’, so that any user can use it. This is also because for testing purpose, and should be deleted before going into a production environment.

    Remove test database and access to it? [Y/n] <-- ENTER

    - Dropping test database...

    ... Success!

    - Removing privileges on test database...

    ... Success!

    Reloading the privilege tables will  make sure that the changes you have  made till now are in effect immediately.

    By reloading the privilege tables will eventually help to make certain that all modifications that have been made yet will take effect immediately.

    Reload privilege tables now? [Y/n] <-- ENTER

    ... Success!

    Cleaning up...

    The installation process has been completed.

  • 2

    How to Install Lighttpd

    Since Lighttpd and PHP-FPM cannot be obtainable from the official CentOS database, so we have to use the Remi PRM database and EPEL database.

    rpm --import


    rpm -ivh epel-release-6-7.noarch.rpm

    rpm --import

    rpm -ivh

    yum install yum-priorities

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

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

    ... and add the line priority=10 to the [epel] section:


    name=Extra Packages for Enterprise Linux 6 - $basearch









    Then do the same for the [remi] section in /etc/yum.repos.d/remi.repo, plus change enabled to 1:

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


    name=Les RPM de remi pour Enterprise Linux $releasever - $basearch









    name=Les RPM de remi en test pour Enterprise Linux $releasever - $basearch






    Now, we can install Lighttpd through this process:

    yum install lighttpd

    Now make the required system startup links for Lighttpd (so that it can automatically initiate Lighttpd every time the system boots) and start it:

    chkconfig --levels 235 lighttpd on

    /etc/init.d/lighttpd start

    In case Lighttpd is unable to start with the given message…

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

    ... open /etc/lighttpd/lighttpd.conf...

    vi /etc/lighttpd/lighttpd.conf

    ... and change server.use-ipv6 from enable to disable:



    ## Use IPv6?


    server.use-ipv6 = "disable"

    Again start Lighttpd, and it will definitely work without any issue.

    /etc/init.d/lighttpd start

    Now type this address on your browser, and this page will appear on your computer screen.

    Lighttpd's default document root is /var/www/lighttpd/ on CentOS 6.3, and the configuration file is /etc/lighttpd/lighttpd.conf.

  • 3

    How to Install PHP5

    PHP5 can be made compatible with Lighttpd with the help of PHP-FPM which we install in this way:

    yum install php-fpm lighttpd-fastcgi

    PHP-FPM is a daemon process that runs a FastCGI server on port 9000.

    Open /etc/php-fpm.d/www.conf...
    vi /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.

    ; RPM: apache Choosed to be able to access some dir as httpd

    user = lighttpd

    ; RPM: Keep a group allowed to write in log dir.

    group = lighttpd


    Now make the system startup links for PHP-FPM and start using it:

    chkconfig --levels 235 php-fpm on

    /etc/init.d/php-fpm start

Leave a Reply

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

4 × = thirty six