• Lighttpd
  • Andre Bogus
  • 289字
  • 2021-08-25 18:06:20

Chapter 2. Configuring and Running Lighttpd

In this chapter, we will learn:

  • How to configure Lighttpd
  • What Selectors are
  • How to use Selectors
  • How to rewrite and redirect requests
  • How to include variables in the configuration files

Now that you have successfully installed Lighttpd onto your system, I will show you how to configure it to serve web pages (yes, just web pages, nothing else) and expand from there. Lighttpd needs a configuration file called lighttpd.conf—in fact it will not run without one. To make it as simple as possible, we start with the absolute minimum:

server.document-root = "/var/www"
mimetype.assign = ("" => "text/html")

Yes, that is all. Of course you should take the path to your website as your document root. Under UNIX, /var/www is a probable path, while Windows users may want to put their site in a place like C:\www\mysite. The mimetype.assign statement simply says that everything is to be served as if it were an HTML page.

Put this lighttpd.conf into the standard directory of your system:

In Windows, all the installers that I tested put the lighttpd.conf file and run scripts under C:\lighttpd by default. However, we might want to change the Lighttpd directory to suit our system, for example, we may want to put it under "Program Files" or on another disk drive. We may alternatively put the lighttpd.conf file into any directory of our choice, but then the run scripts provided with Lighttpd may not work. This is not a big deal though, as we can still start Lighttpd directly from the command line. Note that under most systems, Lighttpd needs to be started from the administrator or root account so that it can listen to port 80.