# nginx启动worker进程数
worker_processes auto;
#Changes the limit on the maximum number of open files (RLIMIT_NOFILE)
for
worker processes.定义进程可以打开的最大文件数,与linux内核相同即可
worker_rlimit_nofile 65535;
# 定义worker进程的优先级,数字越小优先级越高 [-20,19]
worker_priority -20;
events{
# The maximum number of connections that each worker process can handle simultaneously.每个进程同时处理的连接数
worker_connections 10240;
# If multi_accept is disabled, a worker process will accept one
new
connection at a time. Otherwise, a worker process will accept all
new
connections at a time.
multi_accept on;
}
http{
access_log /
var
/log/nginx/access.log main buffer=32k;
# Nginx将使用sendfile内核来调用处理文件传递。
sendfile on;
# 根据权重分配请求到不同服务器,以下配置,当有6个请求时,5个发送到9000端口服务器,1个发送到9001端口服务器
upstream phpload{
server 127.0.0.1:9000 weight=6;
server 127.0.0.1:9001 weight=1;
}
server{
listen 443;
root /data/www/webserver;
index index.php;
location / {
if
(!-e
$request_filename
) {
rewrite ^(.*)$ /index.php?s=
$1
last;
break
;
}
}
location ~ .php($|/){
set
$script
$uri
;
set
$path_info
""
;
if
(
$uri
~
"^(.+.php)(/.+)"
) {
set
$script
$1
;
set
$path_info
$2
;
}
fastcgi_param SCRIPT_FILENAME
$document_root
$script
;
fastcgi_param SCRIPT_NAME
$script
;
fastcgi_param PATH_INFO
$path_info
;
try_files
$uri
=404;
# 使用负载,分发请求到上游php服务器
fastcgi_pass myfastcgi;
fastcgi_index index.php;
include
fastcgi_params;
}
}
}