From Fedora Project Wiki

Revision as of 17:27, 28 March 2013 by Fab (talk | contribs) (Modules Setup)


This is the procedures for deploying a lighttpd + PHP server on Fedora. This has been done on Fedora 17+ which systemd is built in.

Log in as "root" user before doing the followings:

$ su -


Install the "lighttpd", the "lighttpd-fastcgi", and the "php-cli" package.

$ sudo yum install php-cli lighttpd lighttpd-fastcgi

Modules Setup

Check if in /etc/lighttpd/lighttpd.conf the line from below is uncomment:

include "modules.conf"

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

#include "conf.d/fastcgi.conf"

or use sed to to it:

# sed -i 's|#include "conf.d/fastcgi.conf"|include "conf.d/fastcgi.conf"|g' /etc/lighttpd/modules.conf

Open /etc/lighttpd/conf.d/fastcgi.conf and add the following lines:

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

Create a lighttpd accessible directory for the socket:

$ mkdir -p /var/run/lighttpd
$ chmod 775 /var/run/lighttpd
$ chgrp lighttpd lighttpd

Configuration of Runtime

Open the port on the firewall for the incoming connection:

# firewall-cmd --add-service=http

or if you are using iptables

# iptables -I INPUT -p tcp --dport 80 -j ACCEPT

Start lighttpd by default:

# systemctl enable lighttpd.service

Service Restart & Testing

Restart the lighttpd server:

# systemctl restart lighttpd.service

Create a file "test.php" in default home directory "/var/www/lighttpd/", with the following contents:

<?php echo phpinfo(); ?>

Open the page "http://localhost/test.php" for results.