《精通Nginx》——2.2 Nginx的全局配置参数

本节书摘来自异步社区《精通Nginx》一书中的第2章,第2.2节,作者: 【瑞士】Dimitri Aivaliotis 更多章节内容可以访问云栖社区“异步社区”公众号查看。

2.2 Nginx的全局配置参数

全局配置部分被用于配置对整个server都有效的参数和前一个章节中的例外格式。全局部分可能包含配置指令,例如,user和worker_processes,也包括“节、部分(section)”。例如,events,这里没有大括号({})包围全局部分。

在全局部分中,最重要的配置指令都在表2-1中,这些指令将会是你处理的最重要部分。


<a href=https://yqfile.alicdn.com/3472e29b64e8e179bf04f3a469a82b1df5ce60ee.png" >

下面是一个使用这些指令的简短的例子。

we want nginx to run as user www

user www;
the load is CPU-bound and we have 12 cores
worker_processes  12;
explicitly specifying the path to the mandatory error log
error_log  /var/log/nginx/error.log;
also explicitly specifying the path to the pid file
pid        /var/run/nginx.pid;
sets up a new configuration context for the 'events' module
events {
    # we're on a Solaris-based system and have determined that nginx
    # will stop responding to new requests over time with the default
    # connection-processing mechanism, so we switch to the second-best
    use /dev/poll;
    # the product of this number and the number of worker_processes
    # indicate s how many simultaneous connections per IP:port pair are
    # accepted
    worker_connections  2048;
}

这一部分应该放置在nginx.conf文件的顶部。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值