修改nginx配置文件nginx.conf
-
增加work_rlimit_nofile和worker_connections数量
-
禁用keepalive_timeout。
-
user www www; #统一使用www权限,包括php-fpm
-
worker_processes auto; #nginx进程数,建议按照cpu 数目来指定,一般为它的倍数
-
worker_rlimit_nofile 65535; #一个nginx进程打开的最多文件描述符数目,理论值应该是最多打开文件数(ulimit -n)与nginx 进程数相除,但是nginx 分配请求并不是那么均匀,所以最好与ulimit -n 的值保持一致
-
events { use epoll; #使用epoll的I/O模型 worker_connections 65535; #每个进程允许的最多连接数, 理论上每台nginx 服务器的最大连接数为worker_processes*worker_connections multi_accept on; }
-
http { keepalive_timeout 120; #开启Gzip gzip on; gzip_buffers 16 8k; gzip_comp_level 6; gzip_http_version 1.1; gzip_min_length 256; gzip_proxied any; gzip_vary on; gzip_types text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml text/javascript application/javascript application/x-javascript text/x-json application/json application/x-web-app-manifest+json text/css text/plain text/x-component font/opentype application/x-font-ttf application/vnd.ms-fontobject image/x-icon; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; #开启缓存配置 open_file_cache max=1000 inactive=20s; open_file_cache_valid 30s; open_file_cache_min_uses 2; open_file_cache_errors on; }
站点配置
/usr/local/nginx/conf/vhost/default.confserver { listen 80 default backlog=2048;}