官网地址:http://code.google.com/p/mongoose/
Mongoose的老家在Google Codec网站,属于开放源代码小型Web服务器,轻量级、高性能是它的主要优点,其他特色也不少:
多平台支持。目前支持Windows、Linux、UNIX和Mac。
CGI、SSL和SSI支持,还支持Digest(MD5)身份认证,断点续传。
基于IP的访问限制。
很小巧。Windows下大小为60KB,Linux下更是只有40KB。
支持多种编程语言。目前的2.8版本支持C/C++、Python、C#,到2.9版本将多支持Ruby、Lua等。
配置mongoose.conf文件即可支持PHP,以下是我配置的内容:
error_log_file error.log
cgi_extensions php
# cgi_environment <value>
# put_delete_passwords_file <value>
cgi_interpreter c:\root\php-cgi.exe
# protect_uri <value>
# authentication_domain mydomain.com
# ssi_extensions .shtml,.shtm
# access_log_file <value>
# ssl_chain_file <value>
# enable_directory_listing yes
# global_passwords_file <value>
index_files index.html,index.htm,index.cgi
# enable_keep_alive no
# access_control_list <value>
# max_request_size 16384
# extra_mime_types <value>
#端口
listening_ports 8092
#指定网站根目录,指到本人的Apache服务器里(根据自己的需要配置)
document_root D:\http
# ssl_certificate <value>
# num_threads 10
# run_as_user <value>
配置文件的编写规则:
Format of the configuration file is the same as for the command line options except that each option must be specified on a separate line, leading dashes for option names must be omitted. Lines beginning with '#' and empty lines are ignored.
OPTIONS(选项):
-A htpasswd_file domain_name user_name password Add/edit user's password in the passwords file. Deleting users can be done with any text editor. Functionality is similar to Apache's htdigest utility.
-C cgi_extensions Comma-separated list of CGI extensions. All files having these extensions are treated as CGI scripts. Default: ".cgi,.pl,.php"
-E cgi_environment Extra environment variables to be passed to the CGI script in addition to standard ones. The list must be comma-separated list of X=Y pairs, like this: "VARIABLE1=VALUE1,VARIABLE2=VALUE2". Default: ""
-G put_delete_passwords_file PUT and DELETE passwords file. This must be specified if PUT or DELETE methods are used. Default: ""
-I cgi_interpreter Use cgi_interpreter as a CGI interpreter for all CGI scripts regardless script extension. Default: "". Mongoose decides which interpreter to use by looking at the first line of a CGI script.
-P protect_uri Comma separated list of URI=PATH pairs, specifying that given URIs must be protected with respected password files. Default: ""
-R authentication_domain Authorization realm. Default: "mydomain.com"
-S ssi_extensions Comma separated list of SSI extensions. Unknown SSI directives are silently ignored. Currently, two SSI directives supported, "include" and "exec". Default: "shtml,shtm"
-a access_log_file Access log file. Default: "", no logging is done.
-d enable_directory_listing Enable/disable directory listing. Default: "yes"
-e error_log_file Error log file. Default: "", no errors are logged.
-g global_passwords_file Location of a global passwords file. If set, per-directory .htpasswd files are ignored, and all requests must be authorised against that file. Default: ""
-i index_files Comma-separated list of files to be treated as directory index files. Default: "index.html,index.htm,index.cgi"
-l access_control_list Specify access control list (ACL). ACL is a comma separated list of IP subnets, each subnet is prepended by '-' or '+' sign. Plus means allow, minus means deny. If subnet mask is omitted, like "-1.2.3.4", then it means single IP address. Mask may vary from 0 to 32 inclusive. On each request, full list is traversed, and last match wins. Default setting is to allow all. For example, to allow only 192.168/16 subnet to connect, run "mongoose -0.0.0.0/0,+192.168/16". Default: ""
-m extra_mime_types Extra mime types to recognize, in form "extension1=type1,exten- sion2=type2,...". Extension must include dot. Example: "mongoose -m .cpp=plain/text,.java=plain/text". Default: ""
-p listening_ports Comma-separated list of ports to listen on. If the port is SSL, a letter 's' must be appeneded, for example, "-p 80,443s" will open port 80 and port 443, and connections on port 443 will be SSL-ed. It is possible to specify an IP address to bind to. In this case, an IP address and a colon must be prepended to the port number. For example, to bind to a loopback interface on port 80 and to all interfaces on HTTPS port 443, use "mongoose -p 127.0.0.1:80,443s". Default: "8080"
-r document_root Location of the WWW root directory. A comma separated list of URI_PREFIX=DIRECTORY pairs could be appended to it, allowing Mon- goose to serve from multiple directories. For example, "mongoose -p /var/www,/config=/etc,/garbage=/tmp". Default: "."
-s ssl_certificate Location of SSL certificate file. Default: ""
-t num_threads Number of worker threads to start. Default: "10"
-u run_as_user Switch to given user's credentials after startup. Default: ""