Photo of David Winter

david winter

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.