2014-06-29 wcdj
学习和使用nginx,首先需要了解nginx的配置选项的含义,比较好的学习方法是,先保存复制一份默认的nginx.conf配置,然后开始动手修改自己感兴趣的配置,尝试各种功能。在遇到配置错误时,nginx可以很友好地给我们做出提示:
比如在添加配置时少一个分号,nginx会提示如下的错误信息:
root@mba:sbin#./nginx
nginx: [emerg] directive "daemon" is not terminated by ";" in /Users/gerryyang/LAMP/nginx/install/nginx-1.7.2/conf/nginx.conf:19
比如在Mac OS X上指定event为epoll时,会提示如下错误信息:
root@mba:sbin#./nginx
nginx: [emerg] invalid event type "epoll" in /Users/gerryyang/LAMP/nginx/install/nginx-1.7.2/conf/nginx.conf:14
下面是nginx几个核心的配置说明:
(1) accept_mutex的说明
Syntax: | accept_mutex |
---|---|
Default: | accept_mutex on; |
Context: | events |
If accept_mutex
is enabled,worker processes will accept new connections by turn.Otherwise, all worker processes will be notified about new connections,and if volume of new connections is low, some of the worker processesmay just waste system resources.
The use of rtsig connection processing methodrequires
accept_mutex
to be enabled.
Syntax: | accept_mutex_delay |
---|---|
Default: | accept_mutex_delay 500ms; |
Context: | events |
If accept_mutex is enabled, specifies the maximum timeduring which a worker process will try to restart accepting newconnections if another worker process is currently acceptingnew connections.
(2) Connections processing methods的说明
nginx supports a variety of connection processing methods.The availability of a particular method depends on the platform used.On platforms that support several methods nginx will normallyselect the most efficient method automatically.However, if needed, a connection processing method can be selectedexplicitly with the use directive.
The following connection processing methods are supported:
-
select
— standard method.The supporting module is built automatically on platforms that lackmore efficient methods.The--with-select_module
and--without-select_module
configuration parameterscan be used to forcibly enable or disable the build of this module.