User Tools

Site Tools


lighttpd

Lighttpd Home Ref: https://www.howtoforge.com/tutorial/install-lighttpd-with-php-fpm-and-mysql-on-debian/

Installation

  • apt-get install lighttpd
  • Modify /etc/lighttpd/lighttpd.conf
    • set server.document-root to “/home/usr/www”, and “sudo chown www-data:www-data /home/usr/www”
  • start it
sudo /etc/init.d/lighttpd start
#www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
www-data:x:33:33:www-data:/home/usr/www:/bin/bash

Setup php to work with lighttpd

  • Install php from slackpkg
  • Uncomment “include conf.d/fastcgi.conf” in /etc/lighttpd/modules.conf.
  • In the fastcgi section of /etc/lighttpd/lighttpd.conf, copy the following lines below the extisting commented out

fastcgi config.

fastcgi.server = ( ".php" =>
  ( "localhost" =>
    (
    "socket" => "/tmp/php-fastcgi.socket",
    "bin-path" => "/usr/bin/php-cgi -c /etc/lighttpd/php.ini"
    )
  )
)
  • Change the group of /var/lib/php from “apache” to “nobody”. Otherwise php won't be able to use $_SESSION.
  • Test it by browser “http://rabi.chem.purdue.edu/test.php”. If it does not work, make sure first you can run php from command line.
  • Note that required packages: libmcrypt, sqlite, net-snmp, t1lib

The following was copied from doku site

Lighttpd

DokuWiki will run just fine with Lighttpd and PHP through FastCGI.

  1. create /etc/dokuwiki/lighttpd.conf
  2. cd /etc/lighttpd/conf-available
  3. ln /etc/dokuwiki/lighttpd.conf 50-dokuwiki.conf
    1. /etc/lighttpd/conf-available/50-dokuwiki.conf -> /etc/dokuwiki/lighttpd.conf 
  4. enable config with lighttpd-enable-mod dokuwiki
  5. /etc/init.d/lighttpd force-reload

/etc/dokuwiki/lighttpd.conf

alias.url += ("/dokuwiki" => "/usr/share/dokuwiki")

$HTTP["url"] =~ "^/dokuwiki" {
  server.follow-symlink = "enable"
}

$HTTP["url"] =~ "/(\.|_)ht" {
  url.access-deny = ( "" )
}
$HTTP["url"] =~ "^/dokuwiki/(bin|data|inc|conf)" {
  url.access-deny = ( "" )
}

A better version

# DokuWiki configuration
# We assume here that the wiki is accessible via http://wiki.example.com/dokuwiki/
var.dokudir = "/dokuwiki"
 
# make sure those are always served through FastCGI and never as static files
static-file.exclude-extensions = ( ".php" )
 
# deny access completely to these
$HTTP["url"] =~ "/(\.|_)ht" { url.access-deny = ( "" ) }
$HTTP["url"] =~ "^" + var.dokudir + "/(bin|data|inc|conf)/"  { url.access-deny = ( "" ) }
 
# rewrites for dokuwiki
$HTTP["url"] =~ "^" + var.dokudir { index-file.names = ("doku.php") }
url.rewrite-once = (
  "^" + var.dokudir + "/lib/.*$"                     => "$0",
  "^" + var.dokudir + "/_media/(.*)?\?(.*)$"         => var.dokudir + "/lib/exe/fetch.php?media=$1&$2",
  "^" + var.dokudir + "/_media/(.*)$"                => var.dokudir + "/lib/exe/fetch.php?media=$1",
  "^" + var.dokudir + "/_detail/(.*)?\?(.*)$"        => var.dokudir + "/lib/exe/detail.php?media=$1&$2",
  "^" + var.dokudir + "/_detail/(.*)?$"              => var.dokudir + "/lib/exe/detail.php?media=$1",
  "^" + var.dokudir + "/_export/([^/]+)/(.*)\?(.*)$" => var.dokudir + "/doku.php?do=export_$1&id=$2&$3",
  "^" + var.dokudir + "/_export/([^/]+)/(.*)"        => var.dokudir + "/doku.php?do=export_$1&id=$2",
  "^" + var.dokudir + "/doku.php.*"                  => "$0",
  "^" + var.dokudir + "/feed.php.*"                  => "$0",
  "^" + var.dokudir + "/(.*)\?(.*)"                  => var.dokudir + "/doku.php?id=$1&$2",
  "^" + var.dokudir + "/(.*)"                        => var.dokudir + "/doku.php?id=$1"
)
lighttpd.txt · Last modified: 2024/03/14 05:26 by 127.0.0.1