lighttpd and PHP on CentOS 5

Here’s a quick run down on getting lighttpd and php running on CentOS 5.

yum install lighttpd lighttpd-fastcgi php
mkdir /var/run/lighttpd
touch /var/run/lighttpd/php-fastcgi.socket
chown -R lighttpd:lighttpd /var/run/lighttpd/
vim /etc/php.ini

Add in php.ini the following; cgi.fix_pathinfo = 1. Save and close the file.

Now open up /etc/lighttpd/lighttpd.conf. Uncomment the following line "mod_fastcgi", from the server.modules option. Then ensure that the following is uncommented:

fastcgi.server  = ( ".php" =>
    ( "localhost" =>
        (
            "socket" => "/var/run/lighttpd/php-fastcgi.socket",
            "bin-path" => "/usr/bin/php-cgi"
        )
    )
)

Save the file. Now create a test file, /srv/www/lighttpd/index.php and just include <?php phpinfo(); ?>. Now open your favourite browser and visit http://localhost/index.php. You should be greeted with a friendly PHP page, and you’re set to go.

2008-06-22 [, , , ]
  • http://www.zepy.net Neezar

    I’ve searched so many resources how to run lighttpd+PHP on Centos 5 today and finally, after read this simple tutorial, lighttpd can run on my server. Thanks Mate!

    BTW, can you a little explain what is these commands for touch /var/run/lighttpd/php-fastcgi.socket chown -R lighttpd:lighttpd /var/run/lighttpd/

    Because after ran those commands, the lighttpd didn’t give any error again on Centos 5.

  • http://www.smite.de/ rykr

    hi, thank you for this small howto. I’ve followed your instructions and startet lighttpd, but it failed to work with php-scripts. My error.log told me this: (server.c.931) WARNING: unknown config-key: fastcgi.server (ignored)

    It finally started to work after I uncommented the modcgi and modfastcgi lines at the ‘server.modules’ section in /etc/lighttpd/lighttpd.conf.

  • sunny

    centos 5.2

    yum install lighttpd lighttpd-fastcgi php

    Parsing package install arguments No package lighttpd available. No package lighttpd-fastcgi available.

    ????

  • topaussie

    After a few days of intermittently trying to get this combo together, your simple instructions did the trick. The mkdir, touch, chown (my missing pieces) are obvious when you think about it, it would be nice if the lighttpd wiki included those steps. Thanks.

  • Guy

    rykr: First install RPMForge repository then it will install all related packages of Lighttpd.. Thanks

  • http://davidbomba.com/?p=122 Lighttpd Centos | David Bomba
  • http://www.facebook.com/people/Pablo-Andres-Lagos-Maraboli/1176408682 Pablo Andres Lagos Maraboli

    Hello, I got the following error:

    chown -R lighttpd:lighttpd /var/run/lighttpd/

    chown: `lighttpd:lighttpd’: invalid user

blog comments powered by Disqus