Lighttpd
上QQ阅读APP看书,第一时间看更新

Starting Lighttpd by Hand

Lighttpd can be started without the help of a startup script. The path to the Lighttpd executable depends on your system and installation. Given that it is in your path, we can start Lighttpd by using the following command:

lighttpd -f [full path to your config file]

With some distributions (especially some Windows builds), the -f option will be hardcoded, so we cannot and need not supply the configuration file path. When in doubt, refer to the documentation of the installation package.

There are also other command line options that are worth taking a look at:

Now, run Lighttpd from the command line or with the provided startup script and point your browser of choice to http://127.0.0.1/index.html. Given that you have an index.html, you should see it in your browser. If you see it, congratulations!—you have made your first step into a bright future as a Lighttpd user.

Otherwise, we should tackle the problem methodically. First, start Lighttpd with the -t option to see if our configuration is parsed correctly; correct it if necessary. Next, see if the run script/Lighttpd startup failed. If it did, there are three possible culprits:

  1. Port 80 (which is standard for HTTP) is blocked by some other application. In this case, you should see something else in your browser (given that the other application that listens on port 80 speaks HTTP).
  2. Lighttpd does not have sufficient privileges to listen on port 80. Try running Lighttpd as root, or use ports higher than 1024, say, port 8080.
  3. Your Lighttpd installation or package is erroneous. Try another version or visit the forum at http://forum.lighttpd.net and ask for help.

If Lighttpd starts without error, make sure that your index.html is in your document-root directory and readable by the Lighttpd instance. If that does not solve the problem, we will need some debugging to find out what has failed. To do this, extend your lighttpd.conf file to include logging and up to four debug directives:

server.modules += ("mod_accesslog")
server.errorlog = "/var/log/lighttpd/error.log"
# or wherever you want to put it
debug.log-file-not-found = "enabled"
debug.log-request-header = "enabled"
debug.log-request-handling = "enabled"
debug.log-response-header = "enabled"

Now, you can restart Lighttpd, browse at http://127.0.0.1/index.html, and look into your error log to see what went wrong.

Generally, setting options are done with [module].[option] = [value], where value can be a "string", a number, or a boolean (note that instead of "true" and "false" Lighttpd configuration expects "enabled" and "disabled" or a comma-separated list of values in parenthesis (like server.modules). You can also append values to list with [module].[option] += ([values]).