关于nginx的几个核心配置说明

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 on | off;
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 time;
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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值