TutorialConfiguration » History » Revision 6
« Previous |
Revision 6/28
(diff)
| Next »
Anonymous, 2006-02-19 15:10
staticfile.exclude-extensions -> static-file.exclude-extensions
= Configuration =
How much time do you have to setup lighttpd ? 5, 10 or more minutes ?
5 minutesYou want to run a fast, low-resource server for static content ?
{{{
server.document-root = "/var/www/servers/www.example.org/pages/"
server.port = 3000
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".jpg" => "image/jpeg",
".png" => "image/png"
)
}}}
lighttpd will listen on port 3000/tcp and bind to all interfaces default. The few important mimetypes are assigned
and the document-root (the base direcorty that is used for all requests) is set. The files in the document-root have to be
readable by the user starting the webserver.
First, check that your config is ok:
{{{
$ lighttpd -t -f lighttpd.conf
}}}
Now start the server for testing:
{{{
$ lighttpd -D -f lighttpd.conf
}}}
and point your browser to
To stop the server again, just press ctrl-c.
=== a real daemon ===
As you want to run the server in production quite soon you take the next seconds are on security:
{{{
server.document-root = "/var/www/servers/www.example.org/pages/"
server.port = 80
server.username = "www"
server.groupname = "www"
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".jpg" => "image/jpeg",
".png" => "image/png"
)
static-file.exclude-extensions = ( ".fcgi", ".php", ".rb", "~", ".inc" )
index-file.names = ( "index.html" )
}}}
Now the webserver is listing on port 80, the default port for HTTP, and will switch to the user 'www' and the group 'www' as
the server has to be started as root to take control over port 80.
As last step we forbid the access to the source of some files which will be used later for generating dynamic content and rewrite
all requests to a directory to the 'index.html' file in that directory.
Place the configfile in {{{/etc/lighttpd/lighttpd.conf}}} and start the server with:
{{{
$ /etc/init.d/lighttpd start
}}}
To stop it use:
{{{
$ /etc/init.d/lighttpd stop
}}}
( this assumes that you have created that service already as described in TutorialInstallation )
10 minutesConditionals, conditionals, conditionals:
The most important part in lighties configuration is the use of conditionals. They control via simple comparisions or regexes
if a default setting will be overwritten or not.
{{{
server.document-root = "/var/www/servers/www.example.org/pages/"
server.port = 80
server.username = "www"
server.groupname = "www"
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".jpg" => "image/jpeg",
".png" => "image/png"
)
static-file.exclude-extensions = ( ".fcgi", ".php", ".rb", "~", ".inc" )
index-file.names = ( "index.html" )
$HTTP["host"] == "www2.example.org" {
server.document-root = "/var/www/servers/www2.example.org/pages/"
}
}}}
Now we have a new virtual server which will use the same settings as the first server, only the document-root
will be replaced by a new one.
This server shall have a download area which shall print a nice-looking dirlisting:
{{{
server.document-root = "/var/www/servers/www.example.org/pages/"
server.port = 80
server.username = "www"
server.groupname = "www"
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".jpg" => "image/jpeg",
".png" => "image/png"
)
static-file.exclude-extensions = ( ".fcgi", ".php", ".rb", "~", ".inc" )
index-file.names = ( "index.html" )
$HTTP["host"] == "www2.example.org" {
server.document-root = "/var/www/servers/www2.example.org/pages/"
$HTTP["url"] =~ "^/download/" {
dir-listing.activate = "enable"
}
}
}}}
As you see conditonals can be nested: only the /download/ folder and its sub-folders have the directory listings
enabled.
With this basic steps you are ready to read on the other chapters about:
- includes at http://blog.lighttpd.net/articles/2005/11/25/simplify-your-configfiles-with-includes
- php at http://www.lighttpd.net/documentation/fastcgi.html
Now you know the basic setup, includes and might have php or ruby already running. There is alot more to find out.
Most of it is described in examples in the default configuration file that you can find in the {{{doc/}}} directory
of the tarball or at http://trac.lighttpd.net/trac/file/branches/lighttpd-merge-1.4.x/doc/lighttpd.conf
The website also has the manual online:
- http://www.lighttpd.net/documentation/
- the description of the config file structure http://www.lighttpd.net/documentation/configuration.html
as starting point for the configuration.
Updated by Anonymous almost 19 years ago · 6 revisions