DeployLighttpdPHPServer

From FedoraProject

(Difference between revisions)
Jump to: navigation, search
(add systemctl enable)
m (some html stuff removed)
Line 3: Line 3:
 
This is the procedures for deploying a lighttpd + PHP server on Fedora. This has been done on Fedora 17 which systemd is built in.
 
This is the procedures for deploying a lighttpd + PHP server on Fedora. This has been done on Fedora 17 which systemd is built in.
  
<ol>
+
Log in as "root" user before doing the followings:
  <li>
+
$ su -
    Log in as "root" user before doing the followings:
+
    <pre>
+
$ su -
+
    </pre>
+
  </li>
+
</ol>
+
  
 
== Installation ==
 
== Installation ==
<ol>
+
Install the "lighttpd", the "lighttpd-fastcgi", and the "php-cli" package.
  <li>
+
 
    Install package "php-cli".
+
$ sudo yum install php-cli lighttpd lighttpd-fastcgi
  </li>
+
  <li>
+
    Install package "lighttpd".
+
  </li>
+
  <li>
+
    Install package "lighttpd-fastcgi".
+
  </li>
+
  <li>
+
    You can install it at once with yum:
+
    <pre>
+
$ yum install php-cli lighttpd lighttpd-fastcgi
+
    </pre>
+
  </li>
+
</ol>
+
  
 
== Modules Setup ==
 
== Modules Setup ==

Revision as of 17:16, 28 March 2013

Contents

Introduction

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 -

Installation

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

$ sudo yum install php-cli lighttpd lighttpd-fastcgi

Modules Setup

  1. Gain access as user "root".
  2. Open /etc/lighttpd/lighttpd.conf and uncomment the line:
    ##include "modules.conf"
        
  3. Open /etc/lighttpd/modules.conf and uncomment the line:
    #include "conf.d/fastcgi.conf"
        
  4. 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"
                                     )
                                   )
                                )
        
  5. Create a lighttpd accessible directory for the socket:
    $ mkdir -p /var/run/lighttpd
    $ chmod 775 /var/run/lighttpd
    $ chgrp lighttpd lighttpd
        


Configuration of Runtime

  1. Open the port on the firewall, iptables, for the incoming connection:
    $ iptables -I INPUT -p tcp --dport 80 -j ACCEPT
        
  2. Start lighttpd by default:
    $ systemctl enable lighttpd.service
        

Service Restart & Testing

  1. Restart the lighttpd server:
    $ systemctl restart lighttpd.service
        
  2. Create a file "test.php" in default home directory "/var/www/lighttpd/", with the following contents:
    <?php echo phpinfo(); ?>
        
  3. Open the page "http://localhost/test.php" for results.