Table of Contents

How-to setup Lighttpd and php

Files needed

Preparation

  1. Make following directory's:
    • /mnt/HD_a2/lighttpd/ - directory binary (lighttpd, php and modules) files.
    • /mnt/HD_a2/lighttpd/www/ - directory for files you wish to share.
  2. Extract Lighttpd and php archive to /mnt/HD_a2/lighttpd/ directory.
  3. Optionaly you may want to setup php.ini. Default location for this file is /mnt/HD_a2/php.ini. You can get php.ini from php.net. Also look manual before editing.

Lighttpd configuration

Following configuration is meant for lighttpd/lighttpd-pcre and php4/php5

/mnt/HD_a2/lighttpd/lighttpd.conf

#Set path to folder that has files for website
server.document-root = "/mnt/HD_a2/lighttpd/www/"

#Set port to run webserver on (not 80)
server.port = 8080

#Non-default modules needed for css redirect, authentication, server status
server.modules = (
  "mod_alias",
  "mod_auth",
  "mod_status",
  "mod_fastcgi"
  )

#Mimetype assignments
mimetype.assign             = ( 
  ".pdf"          =>      "application/pdf", 
  ".sig"          =>      "application/pgp-signature", 
  ".spl"          =>      "application/futuresplash", 
  ".class"        =>      "application/octet-stream", 
  ".ps"           =>      "application/postscript", 
  ".torrent"      =>      "application/x-bittorrent", 
  ".dvi"          =>      "application/x-dvi", 
  ".gz"           =>      "application/x-gzip", 
  ".pac"          =>      "application/x-ns-proxy-autoconfig", 
  ".swf"          =>      "application/x-shockwave-flash", 
  ".tar.gz"       =>      "application/x-tgz", 
  ".tgz"          =>      "application/x-tgz", 
  ".tar"          =>      "application/x-tar", 
  ".zip"          =>      "application/zip", 
  ".mp3"          =>      "audio/mpeg", 
  ".m3u"          =>      "audio/x-mpegurl", 
  ".wma"          =>      "audio/x-ms-wma", 
  ".wax"          =>      "audio/x-ms-wax", 
  ".ogg"          =>      "audio/x-wav", 
  ".wav"          =>      "audio/x-wav", 
  ".gif"          =>      "image/gif", 
  ".jpg"          =>      "image/jpeg", 
  ".jpeg"         =>      "image/jpeg", 
  ".png"          =>      "image/png", 
  ".bmp"	  =>	  "image/bmp",
  ".xbm"          =>      "image/x-xbitmap", 
  ".xpm"          =>      "image/x-xpixmap", 
  ".xwd"          =>      "image/x-xwindowdump", 
  ".css"          =>      "text/css", 
  ".html"         =>      "text/html", 
  ".htm"          =>      "text/html", 
  ".js"           =>      "text/javascript", 
  ".asc"          =>      "text/plain", 
  ".c"            =>      "text/plain", 
  ".conf"         =>      "text/plain", 
  ".text"         =>      "text/plain", 
  ".txt"          =>      "text/plain", 
  ".dtd"          =>      "text/xml", 
  ".xml"          =>      "text/xml", 
  ".mpeg"         =>      "video/mpeg", 
  ".mpg"          =>      "video/mpeg", 
  ".mov"          =>      "video/quicktime", 
  ".qt"           =>      "video/quicktime", 
  ".avi"          =>      "video/x-msvideo", 
  ".asf"          =>      "video/x-ms-asf", 
  ".asx"          =>      "video/x-ms-asf", 
  ".wmv"          =>      "video/x-ms-wmv", 
  ".bz2"          =>      "application/x-bzip", 
  ".tbz"          =>      "application/x-bzip-compressed-tar", 
  ".tar.bz2"      =>      "application/x-bzip-compressed-tar" 
 ) 

#File to load when path only provided, if not found file listing will display instead
index-file.names  = ( "index.htm", "index.html", "index.php", "default.htm" )
          
#Name and path to server error log
server.errorlog   = "/mnt/HD_a2/lighttpd/lighttpd.error.log"

#Path to css folder
alias.url = ( "/css/" => "/mnt/HD_a2/lighttpd/" )

#Enable directory listing and point to custom css file (supply dsm-g600 IP)
server.dir-listing          = "enable"
dir-listing.external-css    = "http://(your.ip.here)/css/lighttpd.css"

fastcgi.server = ( ".php" =>
  (( "host" => "127.0.0.1", 
     "port" => 1026,
     "bin-path" => "/mnt/HD_a2/lighttpd/php",
     "min-procs" => 2,
     "max-procs" => 4,
     "max-load-per-proc" => 8,
     "idle-timeout" => 50,
     "broken-scriptfilename" => "enable"
  ))
)

#URL to server status page local access only (supply dsm-g600 subnet)
$HTTP["remoteip"] == "192.168.0.0/16" {
  status.status-url = "/server-status"
}

#Authentication configuration
#auth.debug                  = 0
#auth.backend                = "plain"
#auth.backend.plain.userfile = "/mnt/HD_a2/lighttpd/lighttpd-plain.user"

# Set Restrictions:
#
# ( <left-part-of-the-url> =>
#   ( "method" => "digest"/"basic",
#     "realm" => <realm>,
#     "require" => "user=<username>|user=<username>|valid-user" )
# )
#
# <realm> is a string to display in the dialog presented to the user

#auth.require = ( "/downloads/" =>
#                 (
#                   "method"  => "digest",
#                   "realm"   => "DSM-G600 Downloads",
#                   "require" => "valid-user"
#                 )
#               )

Code for fun_plug

You need to enter following code to your fun_plug file if you wish to start webserver automatically at every time to boot up your DSM-G600.

/mnt/HD_a2/lighttpd/lighttpd -f /mnt/HD_a2/lighttpd/lighttpd.conf -m /mnt/HD_a2/lighttpd

Links