#用户和用户组 user www www;
#指令指定处理进程的数量。一般推荐为处理器的个数. 可以适当增加,以避免进程在堵塞在IO等待中。 worker_processes 8;
#错误日志 error_log logs/error.log;
#pid文件位置 pid logs/nginx.pid;
events { #指定 nginx 处理进程的个数,其与总处理量的关系用公式表达如下: #MaxClient = worker_processes * worker_connections #因此这两个数的乘积若大于系统最大可用tcp/ip栈数是没有意义的. worker_connections 1024; }
#HTTP 请求设置 http { #载入mime类型 include mime.types; #默认类型 default_type application/octet-stream;
#日志的格式 log_format main ‘$remote_addr - $remote_user [$time_local] “$request” ‘ ‘$status $body_bytes_sent “$http_referer” ‘ ‘”$http_user_agent” “$http_x_forwarded_for”‘;
#访问日志 access_log logs/access.log main;
#sendfile 指令指定 nginx 是否调用 sendfile 函数(zero copy 方式)来输出文件, #对于普通应用,必须设为 on。 #如果用来进行下载等应用磁盘IO重负载应用,可设置为 off,以平衡磁盘与网络IO处理速度,降低系统 uptime。 sendfile on;
tcp_nopush on;
#keepalive_timeout 0; keepalive_timeout 65;
#gzip on;
#服务器设置 server { #监听端口 listen 80;
#WEB服务主机名 server_name localhost;
#charset utf-8;
#访问日志 access_log logs/localhost.access.log main;
#请求规则 默认请求 location / { #WEB根目录 root /home/www/www; #默认索引文件名 index index.html index.htm index.php; }
#页面不存在处理 error_page 404 /404.html;
#服务器错误定向 error_page 500 502 503 504 /50x.html; location = /50x.html { root /home/www/www; } #PHP 脚本请求全部转发到 FastCGI处理. 使用FastCGI默认配置. location ~ \.php$ { root /home/www/www; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /home/www/www$fastcgi_script_name; include fastcgi_params; }
#禁止访问 .htxxx 文件 location ~ /\.ht { deny all; } } } |