2.2 Nginx的全局配置参数
全局配置部分被用于配置对整个server都有效的参数和前一个章节中的例外格式。全局部分可能包含配置指令,例如,user和worker_processes,也包括“节、部分(section)”。例如,events,这里没有大括号({})包围全局部分。
在全局部分中,最重要的配置指令都在表2-1中,这些指令将会是你处理的最重要部分。
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文件的顶部。
时间: 2024-09-25 14:32:58