nginx主配置文件
1、清空过Nginx配置文件,修改: vim /usr/local/nginx/conf/nginx.conf
# 以那个账户,账户组来运行nginx
user nobody nobody;
# 工作进程:数目。根据硬件调整,通常等于CPU数量或者2倍于CPU。
worker_processes 2;
# 错误日志存放路径
error_log /usr/local/nginx/logs/nginx_errer.log crit;
# PID存放路径
pid /usr/local/nginx/logs/nginx.pid;
# 指定进程可以打开的最大描述符:数目。
worker_rlimit_nofile 51200; events
{
# 使用epoll的I/O 模型 ,可或者选择pool,select
use epoll;
# 每个工作进程的最大连接数量
worker_connections 6000;
} # 设定http服务器,利用它的反向代理功能提供负载均衡支持
http
{
# 设定mime类型,类型由mime.type文件定义
include mime.types;
default_type application/octet-stream;
# 保存服务器名字的hash表是由指令hash_max_size和bucket_size所控制的。
server_names_hash_bucket_size 3526;
server_names_hash_max_size 4096;
log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'
'$host "$request_uri" $status'
'"$http_referer" "$http_user_agent"';
# 指定是否调用sendfile 函数(zero copy 方式)输出文件,普通应用,必须设为on
sendfile on;
  # 此选项允许或禁止使用socke的TCP_CORK的选项,此选项仅在使用sendfile的时候使用
tcp_nopush on;
# keepalive超时时间
keepalive_timeout 30;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
connection_pool_size 256;
# 客户端请求头部的缓冲区大小
client_header_buffer_size 1k;
# 客户请求头缓冲大小
large_client_header_buffers 8 4k;
request_pool_size 4k;
output_buffers 4 32k;
postpone_output 1460;
# 设定通过nginx上传文件的大小
client_max_body_size 10m;
# 把它设为较大数值,例256k,无论任意浏览器,提交小于256k图片都正常。
client_body_buffer_size 256;
client_body_temp_path /usr/local/nginx/client_body_temp;
# proxy_temp_path和proxy_cache_path指定的路径必须在同一分区
proxy_temp_path /usr/local/nginx/proxy_temp;
fastcgi_temp_path /usr/local/nginx/fastcgi_temp;
fastcgi_intercept_errors on;
tcp_nodelay on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 8k;
gzip_comp_level 5;
gzip_http_version 1.1;
gzip_types text/plain application/x-javascript test/css text/htm application/xml; # 虚拟主机配置文件
server {
# 监听端口 设置为默认虚拟主机
listen 80 default;
# 域名
server_name localhost;
# 网页索引类型
index index.html index.htm index.php;
# 网站url
root /usr/local/url;
# 为了安全起见第一个虚拟主机设置禁止访问
deny all;   # 添加允许php访问
location ~ \.php$ {
include fastcgi_params;
# 通信方式,使用socket
# fastcgi_pass 127.0.0.1:9000; TCP/IP通信方式
fastcgi_pass unix:/tmp/php-fcgi.sock;
# 网页索引类型
fastcgi_index index.php;
# 网站根目录URL
fastcgi_param SCRIPT_FILENAME /usr/local/url$fastcgi_script_name;
}
}
# 虚拟主机目录
# include vhosts/*.conf;
}

主配置文件

2、测试配置文件:/usr/local/nginx/sbin/nginx -t
3、重新加载nginx配置文件:/usr/local/nginx/sbin/nginx -s reload
 
注:tcp/ip:127.0.0.1:9000 更加稳定 。
注:socket:unix:/tmp/php-fcgi.sock 并发更高/稳定行没有tcp高。
 
 
 
05-18 01:34