Lighttpd installation
2014-05-28T04:04:00Z.
Lighttpd is a light-weight web server, suitable for serving static content. This article assumes you are going to install and configure Lighttpd on Debian GNU/Linux.
Install Lighttpd
To install Lighttpd, execute the following as root:
aptitude install lighttpd
Configure Lighttpd
The configuration file of Lighttpd is located at
/etc/lighttpd/lighttpd.conf
. A simple configuration looks
like the following:
server.modules = (
"mod_access",
"mod_compress"
)
server.document-root = "/var/www"
server.error-handler-404 = "/404.html"
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
server.errorlog = "/var/log/lighttpd/error.log"
server.pid-file = "/var/run/lighttpd.pid"
server.username = "www-data"
server.groupname = "www-data"
server.port = 9090
server.tag = ""
index-file.names = ( "index.html" )
url.access-deny = ( "~", ".inc" )
compress.cache-dir = "/var/cache/lighttpd/compress/"
compress.filetype = ( "application/javascript", "text/css",
"text/html", "text/plain" )
# HTTPS on port 9191.
$SERVER["socket"] == ":9191"{
ssl.engine = "enable"
ssl.pemfile = "/etc/lighttpd/certificates/lighttpd-ssl-bundle.pem"
}
# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
Explanation of some of the configuration options:
-
server.modules
specifies the modules to be used. -
server.document-root
specifies the root directory of where HTML documents, CSS files, JavaScript files and/ or other static files are located at. -
server.error-handler-404
specifies the URL to be called and returned as response in case of 404 (Not Found) error. -
server.port
specifies which port will Lighttpd listen on for incoming requests. -
server.tag
specifies the header value ofServer
to be included in response. Setting the value to empty string ("") effectively removes the header from response. -
index-file.names
specifies an array of file names which are considered as index file. -
ssl.pemfile
specifies the of a PEM file containing both private key and certificate. If the SSL certificate is CA-signed, you should also specify thessl.ca-file
option which the file contains chain of root and intermediate certificates.
References
Always refer to the official document for configuration syntax and options: