📄 thttpd man page.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0051)http://www.acme.com/software/thttpd/thttpd_man.html -->
<HTML><HEAD><TITLE>thttpd man page</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.3157" name=GENERATOR></HEAD>
<BODY text=#000000 vLink=#4040cc link=#2020ff bgColor=#99cc99><!--AD_START-->
<DIV align=center>
<SCRIPT type=text/javascript><!--google_ad_client = "pub-5759188606642566";google_alternate_ad_url = "http://www.acme.com/donate/ad.html";google_ad_width = 728;google_ad_height = 90;google_ad_format = "728x90_as";google_ad_type = "text_image";google_ad_channel ="8465122053";google_page_url = document.location;google_color_border = ["336699","B0E0E6","FF4500","578A24"];google_color_bg = ["FFFFFF","FFFFFF","FFEBCD","CCFF99"];google_color_link = ["0000FF","000000","DE7008","00008B"];google_color_url = ["008000","336699","E0AD12","00008B"];google_color_text = ["000000","333333","8B4513","000000"];//--></SCRIPT>
<SCRIPT src="thttpd man page.files/show_ads.js" type=text/javascript></SCRIPT>
</DIV>
<TABLE width="100%" bgColor=#cccc99 border=0>
<TBODY>
<TR>
<TD>
<TABLE width="100%" border=2>
<TBODY>
<TR>
<TD></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><!--AD_END--><IMG
height=64 src="thttpd man page.files/anvil_thttpd.gif" width=111 align=right>
<H3>thttpd man page</H3>
<P>[<A href="http://www.acme.com/software/thttpd/thttpd_man.html#NAME">NAME</A>]
[<A
href="http://www.acme.com/software/thttpd/thttpd_man.html#SYNOPSIS">SYNOPSIS</A>]
[<A
href="http://www.acme.com/software/thttpd/thttpd_man.html#DESCRIPTION">DESCRIPTION</A>]
[<A
href="http://www.acme.com/software/thttpd/thttpd_man.html#OPTIONS">OPTIONS</A>]
[<A
href="http://www.acme.com/software/thttpd/thttpd_man.html#CONFIG-FILE">CONFIG-FILE</A>]
[<A
href="http://www.acme.com/software/thttpd/thttpd_man.html#CHROOT">CHROOT</A>]
[<A href="http://www.acme.com/software/thttpd/thttpd_man.html#CGI">CGI</A>] [<A
href="http://www.acme.com/software/thttpd/thttpd_man.html#BASIC_AUTHENTICATION">BASIC
AUTHENTICATION</A>] [<A
href="http://www.acme.com/software/thttpd/thttpd_man.html#THROTTLING">THROTTLING</A>]
[<A
href="http://www.acme.com/software/thttpd/thttpd_man.html#MULTIHOMING">MULTIHOMING</A>]
[<A
href="http://www.acme.com/software/thttpd/thttpd_man.html#CUSTOM_ERRORS">CUSTOM
ERRORS</A>] [<A
href="http://www.acme.com/software/thttpd/thttpd_man.html#NON-LOCAL_REFERERS">NON-LOCAL
REFERERS</A>] [<A
href="http://www.acme.com/software/thttpd/thttpd_man.html#SYMLINKS">SYMLINKS</A>]
[<A
href="http://www.acme.com/software/thttpd/thttpd_man.html#PERMISSIONS">PERMISSIONS</A>]
[<A href="http://www.acme.com/software/thttpd/thttpd_man.html#LOGS">LOGS</A>]
[<A
href="http://www.acme.com/software/thttpd/thttpd_man.html#SIGNALS">SIGNALS</A>]
[<A href="http://www.acme.com/software/thttpd/thttpd_man.html#SEE_ALSO">SEE
ALSO</A>] [<A
href="http://www.acme.com/software/thttpd/thttpd_man.html#THANKS">THANKS</A>]
[<A
href="http://www.acme.com/software/thttpd/thttpd_man.html#AUTHOR">AUTHOR</A>]
<HR>
<PRE>thttpd(8) MAINTENANCE COMMANDS thttpd(8)
</PRE>
<H4><A name=NAME>NAME</A></H4>
<P>thttpd - tiny/turbo/throttling HTTP server
<H4><A name=SYNOPSIS>SYNOPSIS</A></H4>
<P>thttpd [-C configfile] [-p port] [-d dir] [-dd data_dir] [-r|-nor] [-s|-nos]
[-v|-nov] [-g|-nog] [-u user] [-c cgipat] [-t throttles] [-h host] [-l logfile]
[-i pidfile] [-T charset] [-P P3P] [-M maxage] [-V] [-D]
<H4><A name=DESCRIPTION>DESCRIPTION</A></H4>
<P>thttpd is a simple, small, fast, and secure HTTP server. It doesn't have a
lot of special features, but it suffices for most uses of the web, it's about as
fast as the best full-featured servers (Apache, NCSA Netscape), and it has one
extremely useful feature (URL-traffic-based throttling) that no other server
currently has.
<H4><A name=OPTIONS>OPTIONS</A></H4>
<DL>
<DT>-C
<DD>Specifies a config-file to read. All options can be set either by
command-line flags or in the config file. See <A
href="http://www.acme.com/software/thttpd/thttpd_man.html#CONFIG-FILE">below</A>
for details.
<DT>-p
<DD>Specifies an alternate port number to listen on. The default is 80. The
config-file option name for this flag is "port", and the config.h option is <A
href="http://www.acme.com/software/thttpd/options.html#DEFAULT_PORT">DEFAULT_PORT</A>.
<DT>-d
<DD>Specifies a directory to chdir() to at startup. This is merely a
convenience - you could just as easily do a cd in the shell script that
invokes the program. The config-file option name for this flag is "dir", and
the config.h options are <A
href="http://www.acme.com/software/thttpd/options.html#WEBDIR"></A>, <A
href="http://www.acme.com/software/thttpd/options.html#USE_USER_DIR"></A>.
<DT>-r
<DD>Do a chroot() at initialization time, restricting file access to the
program's current directory. If -r is the compiled-in default, then -nor
disables it. See <A
href="http://www.acme.com/software/thttpd/thttpd_man.html#CHROOT">below</A>
for details. The config-file option names for this flag are "chroot" and
"nochroot", and the config.h option is <A
href="http://www.acme.com/software/thttpd/options.html#ALWAYS_CHROOT">ALWAYS_CHROOT</A>.
<DT>-dd
<DD>Specifies a directory to chdir() to after chrooting. If you're not
chrooting, you might as well do a single chdir() with the -d flag. If you are
chrooting, this lets you put the web files in a subdirectory of the chroot
tree, instead of in the top level mixed in with the chroot files. The
config-file option name for this flag is "data_dir".
<DT>-nos
<DD>Don't do explicit symbolic link checking. Normally, thttpd explicitly
expands any symbolic links in filenames, to check that the resulting path
stays within the original document tree. If you want to turn off this check
and save some CPU time, you can use the -nos flag, however this is not
recommended. Note, though, that if you are using the chroot option, the
symlink checking is unnecessary and is turned off, so the safe way to save
those CPU cycles is to use chroot. The config-file option names for this flag
are "symlinkcheck" and "nosymlinkcheck".
<DT>-v
<DD>Do el-cheapo virtual hosting. If -v is the compiled-in default, then -nov
disables it. See <A
href="http://www.acme.com/software/thttpd/thttpd_man.html#MULTIHOMING">below</A>
for details. The config-file option names for this flag are "vhost" and
"novhost", and the config.h option is <A
href="http://www.acme.com/software/thttpd/options.html#ALWAYS_VHOST">ALWAYS_VHOST</A>.
<DT>-g
<DD>Use a global passwd file. This means that every file in the entire
document tree is protected by the single .htpasswd file at the top of the
tree. Otherwise the semantics of the .htpasswd file are the same. If this
option is set but there is no .htpasswd file in the top-level directory, then
thttpd proceeds as if the option was not set - first looking for a local
.htpasswd file, and if that doesn't exist either then serving the file without
any password. If -g is the compiled-in default, then -nog disables it. The
config-file option names for this flag are "globalpasswd" and
"noglobalpasswd", and the config.h option is <A
href="http://www.acme.com/software/thttpd/options.html#ALWAYS_GLOBAL_PASSWD">ALWAYS_GLOBAL_PASSWD</A>.
<DT>-u
<DD>Specifies what user to switch to after initialization when started as
root. The default is "nobody". The config-file option name for this flag is
"user", and the config.h option is <A
href="http://www.acme.com/software/thttpd/options.html#DEFAULT_USER">DEFAULT_USER</A>.
<DT>-c
<DD>Specifies a wildcard pattern for CGI programs, for instance "**.cgi" or
"/cgi-bin/*". See <A
href="http://www.acme.com/software/thttpd/thttpd_man.html#CGI">below</A> for
details. The config-file option name for this flag is "cgipat", and the
config.h option is <A
href="http://www.acme.com/software/thttpd/options.html#CGI_PATTERN">CGI_PATTERN</A>.
<DT>-t
<DD>Specifies a file of throttle settings. See <A
href="http://www.acme.com/software/thttpd/thttpd_man.html#THROTTLING">below</A>
for details. The config-file option name for this flag is "throttles".
<DT>-h
<DD>Specifies a hostname to bind to, for multihoming. The default is to bind
to all hostnames supported on the local machine. See <A
href="http://www.acme.com/software/thttpd/thttpd_man.html#MULTIHOMING">below</A>
for details. The config-file option name for this flag is "host", and the
config.h option is <A
href="http://www.acme.com/software/thttpd/options.html#SERVER_NAME">SERVER_NAME</A>.
<DT>-l
<DD>Specifies a file for logging. If no -l argument is specified, thttpd logs
via syslog(). If "-l /dev/null" is specified, thttpd doesn't log at all. The
config-file option name for this flag is "logfile".
<DT>-i
<DD>Specifies a file to write the process-id to. If no file is specified, no
process-id is written. You can use this file to send signals to thttpd. See <A
href="http://www.acme.com/software/thttpd/thttpd_man.html#SIGNALS">below</A>
for details. The config-file option name for this flag is "pidfile".
<DT>-T
<DD>Specifies the character set to use with text MIME types. The default is
iso-8859-1. The config-file option name for this flag is "charset", and the
config.h option is <A
href="http://www.acme.com/software/thttpd/options.html#DEFAULT_CHARSET">DEFAULT_CHARSET</A>.
<DT>-P
<DD>Specifies a P3P server privacy header to be returned with all responses.
See <A href="http://www.w3.org/P3P/">http://www.w3.org/P3P/</A> for details.
Thttpd doesn't do anything at all with the string except put it in the P3P:
response header. The config-file option name for this flag is "p3p".
<DT>-M
<DD>Specifies the number of seconds to be used in a "Cache-Control: max-age"
header to be returned with all responses. An equivalent "Expires" header is
also generated. The default is no Cache-Control or Expires headers, which is
just fine for most sites. The config-file option name for this flag is
"max_age".
<DT>-V
<DD>Shows the current version info.
<DT>-D
<DD>This was originally just a debugging flag, however it's worth mentioning
because one of the things it does is prevent thttpd from making itself a
background daemon. Instead it runs in the foreground like a regular program.
This is necessary when you want to run thttpd wrapped in a little shell script
that restarts it if it exits. </DD></DL>
<H4><A name=CONFIG-FILE>CONFIG-FILE</A></H4>
<P>All the command-line options can also be set in a config file. One advantage
of using a config file is that the file can be changed, and thttpd will pick up
the changes with a restart.
<P>The syntax of the config file is simple, a series of "option" or
"option=value" separated by whitespace. The option names are listed above with
their corresponding command-line flags.
<H4><A name=CHROOT>CHROOT</A></H4>
<P>chroot() is a system call that restricts the program's view of the filesystem
to the current directory and directories below it. It becomes impossible for
remote users to access any file outside of the initial directory. The
restriction is inherited by child processes, so CGI programs get it too. This is
a very strong security measure, and is recommended. The only downside is that
only root can call chroot(), so this means the program must be started as root.
However, the last thing it does during initialization is to give up root access
by becoming another user, so this is safe.
<P>The program can also be compile-time configured to always do a chroot(),
without needing the -r flag.
<P>Note that with some other web servers, such as NCSA httpd, setting up a
directory tree for use with chroot() is complicated, involving creating a bunch
of special directories and copying in various files. With thttpd it's a lot
easier, all you have to do is make sure any shells, utilities, and config files
used by your CGI programs and scripts are available. If you have CGI disabled,
or if you make a policy that all CGI programs must be written in a compiled
language such as C and statically linked, then you probably don't have to do any
setup at all.
<P>However, one thing you should do is tell syslogd about the chroot tree, so
that thttpd can still generate syslog messages. Check your system's syslodg man
page for how to do this. In FreeBSD you would put something like this in
/etc/rc.conf:
<BLOCKQUOTE><CODE>syslogd_flags="-l /usr/local/www/data/dev/log"
</CODE></BLOCKQUOTE>Substitute in your own chroot tree's pathname, of course.
Don't worry about creating the log socket, syslogd wants to do that itself. (You
may need to create the dev directory.) In Linux the flag is -a instead of -l,
and there may be other differences.
<P>Relevant config.h option: <A
href="http://www.acme.com/software/thttpd/options.html#ALWAYS_CHROOT">ALWAYS_CHROOT</A>.
<H4><A name=CGI>CGI</A></H4>
<P>thttpd supports the CGI 1.1 spec.
<P>In order for a CGI program to be run, its name must match the pattern
specified either at compile time or on the command line with the -c flag. This
is a simple shell-style filename pattern. You can use * to match any string not
including a slash, or ** to match any string including slashes, or ? to match
any single character. You can also use multiple such patterns separated by |.
The patterns get checked against the filename part of the incoming URL. Don't
forget to quote any wildcard characters so that the shell doesn't mess with
them.
<P>Restricting CGI programs to a single directory lets the site administrator
review them for security holes, and is strongly recommended. If there are
individual users that you trust, you can enable their directories too.
<P>If no CGI pattern is specified, neither here nor at compile time, then CGI
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -