FrequentlyAskedQuestions » History » Revision 62
« Previous |
Revision 62/83
(diff)
| Next »
spaam, 2008-11-23 16:10
- Table of contents
- FAQs
- Where to get help?
- General
- How do I bind to more than one address?
- What kind of environment does server.error-handler-404 set up?
- Why is server.error-handler-404 serving 200 instead of 404?
- How do I protect a directory with a password?
- Can I use Apache Modules with lighttpd?
- Can I use SVN over WebDAV with lighttpd?
- What is lighttpd's equivalent to Apache's "Options +!MultiViews"?
- Why do I still get a 403 status, even though the permissions on my doc root directory and its contents are set to 755?
- FastCGI
- Where is the spawn-php program/script available from? it's mentioned in docs but not available in the distributed package (1.3.7)
- Is there an su-exec wrapper available?
- How do I exclude a certain directory from FastCGI?
- I get the error "No input file specified" when trying to use PHP
- How many php CGI processes will lighttpd spawn?
- What does %1/$1 mean?
- What does "(server.c.XXX) connection closed - write-request-timeout: YY" in my error log mean?
- Why: 'unexpected end-of-file (perhaps the fastcgi process died)'? or random '500 - Internal Server Error'
- SSL
- MacOSX
FAQs¶
Where to get help?¶
IRC: freenode, channel #lighttpd
Mailing list: WikiStart, http://news.gmane.org/gmane.comp.web.lighttpd.
General¶
How do I bind to more than one address?¶
Use server.bind and server.port to bind to the first port and then the $SERVER!["socket"] conditional to bind to the rest (it will 'magically' bind to the specified socket).
Example that exposes /server-status to an internal IP only (note that it's perfectly valid to leave the body of the conditional empty):
server.port = 80 server.bind = "192.0.2.1" $SERVER["socket"] == "192.168.2.100:80" { status.status-url = "/server-status" } $SERVER["socket"] == "/path/to/unix_domain_socket:1" { }
This can also be combined with SSL.
What kind of environment does server.error-handler-404 set up?¶
The environment (which is relevant when using CGI or FastCGI) is quite normal, but observe the following:
- The REQUEST_URI is the original request, and has nothing to do with where the redirect points to.
- QUERY_STRING is not set, so you have to parse the REQUEST_URI yourself to get it.
- Likewise, PATH_INFO isn't set.
- SCRIPT_NAME is set according to the handler, not according to the original URI.
Why is server.error-handler-404 serving 200 instead of 404?¶
Quote from Jan:
Yes. As we handle the error we generate a something new. If you just want to send a custom-404 errorpage, there is server.errorfile-prefix
For further information read the server.errorfile-prefix entry in configuration info.
How do I protect a directory with a password?¶
Look in the doc/authentication.txt
If you're converting from Apache, htpasswd authentication backend is what you're looking for.
See also HowToAuthenticationFromMultipleFiles
Can I use Apache Modules with lighttpd?¶
No, Apache modules are not compatible with lighttpd.
Can I use SVN over WebDAV with lighttpd?¶
No, use Apache. If you would like, you can proxy requests to Apache through lighttpd.
What is lighttpd's equivalent to Apache's "Options +!MultiViews"?¶
Why do I still get a 403 status, even though the permissions on my doc root directory and its contents are set to 755?¶
Nine times out of ten (in IRC support), you have forgotten to check the permissions on one of the parent directories. Double check each directory in your path to insure the lighttpd user can access the nested doc root.
FastCGI¶
Where is the spawn-php program/script available from? it's mentioned in docs but not available in the distributed package (1.3.7)¶
If you install lighttpd (http://lighttpd.net/download/INSTALL), the spawn-fcgi binary is installed automatically (to /usr/bin/spawn-fcgi by default).
The spawn-php.sh script can be found here: http://www.lighttpd.net/download/spawn-php.sh
Is there an su-exec wrapper available?¶
Not officially, but Sune Foldager coded one especially for lighttpd which you can grab here. It's very easy to use, but has not yet been extensively tested so a little caution is advised. On the other hand, the source is very small so it's easy to get a security overview. Instructions and usage examples (with lighttpd) are in the README.
How do I exclude a certain directory from FastCGI?¶
$HTTP["url"] !~ "^/no-fcgi/" { # to exclude multiple directories: $HTTP["url"] !~ "^/(?:no-fcgi1|foo/no-fcgi2|bar)/" { fastcgi.server = ( "/" => ... ) }
You can also use server.error-handler-404 to redirect all non-existent files to FastCGI (see LighttpdOnRails for an example), but you should not. It is known to have unexpected side effects and is more a hack than a real solution. Use mod_magnet whenever you need such changes, darix provides very good scripts (which should fit a lot of web apps) at his website.
I get the error "No input file specified" when trying to use PHP¶
Sadly, this error message can mean a lot of things. A common explanation attempt: PHP is unable to locate or open the file which it is supposed to parse. This can have a lot of reasons:- You forgot to add '''cgi.fix_pathinfo=1 to your php.ini''' file
See the comments in the PHP docs. The issue here is that the environment variable SCRIPT_FILENAME is not being passed to PHP. - Make sure you did not set doc_root or userdir in php.ini, or if you have set it, make sure it has the correct value (doc_root should match lighttpd's server.document-root option in this case)
- If open_basedir is set, make sure the requested file is below one of the directories which is specified there. In the past PHP parsed files which were not inside open_basedir as well, but this security problem was fixed (in php-5.2.3 or so).
- If you are running PHP with different permissions than lighttpd (spawn-fcgi with -u/-g, execwrap, suexec, ...), check that PHP can really read the file
If you are unable to find / fix the problem, you can use strace to see if it is a (OS-related) permission problem (look out for stat*(...YOURFILE...) = RETURNCODE). It might help to set max-procs to 1 and PHP_FCGI_CHILDREN as well (see [[lighttpd:Docs:ModFastCGI|mod_fastcgi docs) in that case, so that you can easily attach strace to the correct php-cgi process.
How many php CGI processes will lighttpd spawn?¶
lighttpd has three configuration options that control how many php-cgi processes will run:
- PHP_FCGI_CHILDREN (defaults to 1)
- max-procs (default 4)
- min-procs is completely ignored in recent lighttpd releases (there is no adaptive spawning anymore)
When lighttpd starts, it will launch max-procs parent php processes. Each parent process then pre-forks PHP_FCGI_CHILDREN child processes. For example, if max-procs are 4 and PHP_FCGI_CHILDREN is 16, lighttpd will start max-procs x ( PHP_FCGI_CHILDREN + 1). In our case: 4 * ( 16 + 1 ) = 68 (4 watcher processes which do not handle requests, 64 real php backends which serve requests).
If you are using an opcode cache such as eAccelerator, XCache or similar it's advisable to keep max-procs at a very low number (1 is perfectly fine) and raise PHP_FCGI_CHILDREN instead. Those opcode caches will create a separate memory space for each parent process, otherwise, which is not what one would call "efficient memory usage" in that case.. If you leave max-procs at 4, you'll end up with four separate opcode memory cache segments.
Note that setting PHP_FCGI_MAX_REQUESTS is recommended to avoid possible memory leak side-effects.
What does %1/$1 mean?¶
It's just "lighty speak" for [http://www.regular-expressions.info/brackets.html backreferences]]. (See doc/rewrite.txt and doc/redirect.txt.)
%n is used to denote a backreference on the conditional, and $n is used to backreference on the redirect/rewrite regex. If you need to learn about regexen, Regular-Expressions.info is as good a place to start as any.
What does "(server.c.XXX) connection closed - write-request-timeout: YY" in my error log mean?¶
This error means that a client connection has timed out and lighttpd has closed the connection. This error on its own is not something to worry about as it can occur regularly during the course of normal site operation. The default timeout is 360 seconds and can be set using server.max-write-idle.
Why: 'unexpected end-of-file (perhaps the fastcgi process died)'? or random '500 - Internal Server Error'¶
If you are using FastCGI with PHP then this may be caused by using PHP extensions that are unstable. For example the following configuration caused my lighttpd install to respond sometimes to identical queries with '500 - Internal Server Error' and sometimes with the page requested. The issue was fixed by removing the APD 'extension' line in the relevant PHP configuration file.
PHP 5.1.6-pl6-gentoo (cgi-cgi) (built: Feb 8 2007 11:14:58) Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies with Advanced PHP Debugger (PAD) v0.9, , by George Schlossnagle
Note that in php5.2.5 there is also this bug
http://bugs.php.net/bug.php?id=43295
which has similar symtoms, but needs a patch to PHP
or wait until 5.2.6 since the patch is committed to php's CVS by dimitry.
SSL¶
Microsoft Internet Explorer reports "bad data from server" when surfing an SSL-enabled Lighttpd site¶
This is most likely because of some known bugs in the implementation of SSL in some versions of MSIE.
The current solution (equivalent of using SetEnvIf in Apache) is using the following configuration snippet:
$HTTP["useragent"] =~ "MSIE" { server.max-keep-alive-requests = 0 }
(from http://article.gmane.org/gmane.comp.web.lighttpd/3447)
MacOSX¶
Lighttpd crashes when using server.event-handler="poll" in MacOSX
Configure lighttpd to use kqueue as the event-handler:¶
server.event-handler = "freebsd-kqueue"
See also: server.event-handler option
Updated by spaam about 16 years ago · 62 revisions