From Fedora Project Wiki

(change to html OL)
m (Service Restart & Testing: remove category)
 
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
  
 
== Introduction ==
 
== 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.
+
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>
 
$ su -c "yum install php-cli lighttpd lighttpd-fastcgi"
 
    </pre>
 
  </li>
 
</ol>
 
  
 
== Modules Setup ==
 
== Modules Setup ==
<ol>
+
Check if in /etc/lighttpd/lighttpd.conf the line from below is uncomment:
  <li>
+
 
    Gain access as user "root".
+
include "modules.conf"
  </li>
+
 
  <li>
+
Open /etc/lighttpd/modules.conf and uncomment the line:
    Open /etc/lighttpd/lighttpd.conf and uncomment the line:
+
 
    <pre>
+
#include "conf.d/fastcgi.conf"
##include "modules.conf"
+
 
    </pre>
+
or use sed to to it:
  </li>
+
 
  <li>
+
# sed -i 's|#include "conf.d/fastcgi.conf"|include "conf.d/fastcgi.conf"|g' /etc/lighttpd/modules.conf
    Open /etc/lighttpd/modules.conf and uncomment the line:
 
    <pre>
 
#include "conf.d/fastcgi.conf"
 
    </pre>
 
  </li>
 
  <li>
 
    Open /etc/lighttpd/conf.d/fastcgi.conf and add the following lines:
 
    <pre>
 
fastcgi.server            = ( ".php" =>
 
                              ( "localhost" =>
 
                                (
 
                                  "socket" => "/var/run/lighttpd/php-fastcgi.socket",
 
                                  "bin-path" => "/usr/bin/php-cgi"
 
                                )
 
                              )
 
                            )
 
    </pre>
 
  </li>
 
  <li>
 
    Create a lighttpd accessible directory for the socket:
 
    <pre>
 
mkdir -p /var/run/lighttpd
 
chmod 775 /var/run/lighttpd
 
chgrp lighttpd lighttpd
 
    </pre>
 
  </li>
 
</ol>
 
  
 +
 +
Open /etc/lighttpd/conf.d/fastcgi.conf and add the following lines:
 +
<pre>
 +
fastcgi.server = ( ".php" =>
 +
                  ( "localhost" =>
 +
                    (
 +
                      "socket" => "/var/run/lighttpd/php-fastcgi.socket",
 +
                      "bin-path" => "/usr/bin/php-cgi"
 +
                    )
 +
                  )
 +
                )
 +
</pre>
 +
 +
Create a lighttpd accessible directory for the socket:
 +
 +
<pre>
 +
# mkdir -p /var/run/lighttpd
 +
# chmod 775 /var/run/lighttpd
 +
# chgrp lighttpd /var/run/lighttpd
 +
</pre>
  
 
== Configuration of Runtime ==
 
== Configuration of Runtime ==
<ol>
+
Open the port on the firewall for the incoming connection:
  <li>
+
 
    Open the port on the firewall, iptables, for the incoming connection:
+
# firewall-cmd --permanent --add-service=http
    <pre>
+
 
$ iptables -I INPUT -p tcp --dport 80 -j ACCEPT
+
and then reload it:
    </pre>
+
 
  </li>
+
# firewall-cmd --reload
</ol>
+
 
 +
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 ==
 
== Service Restart & Testing ==
<ol>
+
Restart the lighttpd server:
  <li>
+
 
    Restart the lighttpd server:
+
# systemctl restart lighttpd.service
    <pre>
+
 
systemctl restart lighttpd.service
+
Create a file "test.php" in default home directory "/var/www/lighttpd/", with the following contents:
    </pre>
+
 
  </li>
+
<?php echo phpinfo(); ?>
  <li>
+
 
    Create a file "test.php" in default home directory "/var/www/lighttpd/", with the following contents:
+
Open the page "http://localhost/test.php" for results.
    <pre>
 
<?php echo phpinfo(); ?>
 
    </pre>
 
  </li>
 
  <li>
 
    Open the page "http://localhost/test.php" for results.
 
  </li>
 
</ol>
 
  
[[Category:Kaio]]
 
 
[[Category:Web]]
 
[[Category:Web]]

Latest revision as of 16:50, 14 December 2014

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

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 /var/run/lighttpd

Configuration of Runtime

Open the port on the firewall for the incoming connection:

# firewall-cmd --permanent --add-service=http

and then reload it:

# firewall-cmd --reload

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.