Nginx配置文件详解
2015-08-13 15:11
134 查看
[root@server1 sbin]# vim /usr/local/nginx/conf/nginx.conf
user
nobody;
//定义nginx运行的用户和组
worker_processes
1;
//nginx进程数,建议设置为等于cpu总核心数
error_log
logs/error.log;
//全局错误日志定义的类型 [ debug | info | notice | warn | error ]
pid
logs/nginx.pid;
//进程pid文件
events {
worker_connections
1024;
//单个进程最大的连接数
}
//设置http服务器,作为反向代理功能提供负载均衡
http {
include
mime.types;
default_type
application/octet-stream;
//默认文件类型
sendfile
on;
//开启高效文件传输模式,sendfile指令nginx是否调用sendfile用来输出文件,对普通文件可以设为on,但如果用来下载应用磁盘I/O重负载应用,可设置为off,以平衡磁盘与网络I/O处理速度
#tcp_nopush
on; //防止网络阻塞
keepalive_timeout
65;
//连接超时时间超过65秒则断开连接
#gzip
on;
//开启gzip压缩
//设置负载均衡的服务器列表
upstream
westos {
server
172.25.16.1 weight=3;
server
172.25.16.2 weight=1;
}
//虚拟主机的配置
server
{
listen
80;
server_name
localhost;
//域名可以有多个,用空格隔开
//默认请求
location / {
root
html;
//定义服务器默认访问站点目录
index index.html
index.html; //索引文件的名称
}
//定义错误提示页面
error_page 500 502 503
504 /50x.html;
location = /50x.html {
root html;
}
//对php后缀结尾的文件请求采用负载均衡请求
location ~ \.php$ {
proxy_pass
westos;
//将请求转向westos定义的服务器列表
}
//php脚本请求全部处理转发到FastCGI处理
location ~ \.php$ {
root
html;
fastcgi_pass
127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
/scripts$fastcgi_script_name;
include
fastcgi_params;
}
//禁止访问.htxx文件
location ~ /\.ht {
deny all;
}
}
user
nobody;
//定义nginx运行的用户和组
worker_processes
1;
//nginx进程数,建议设置为等于cpu总核心数
error_log
logs/error.log;
//全局错误日志定义的类型 [ debug | info | notice | warn | error ]
pid
logs/nginx.pid;
//进程pid文件
events {
worker_connections
1024;
//单个进程最大的连接数
}
//设置http服务器,作为反向代理功能提供负载均衡
http {
include
mime.types;
default_type
application/octet-stream;
//默认文件类型
sendfile
on;
//开启高效文件传输模式,sendfile指令nginx是否调用sendfile用来输出文件,对普通文件可以设为on,但如果用来下载应用磁盘I/O重负载应用,可设置为off,以平衡磁盘与网络I/O处理速度
#tcp_nopush
on; //防止网络阻塞
keepalive_timeout
65;
//连接超时时间超过65秒则断开连接
#gzip
on;
//开启gzip压缩
//设置负载均衡的服务器列表
upstream
westos {
server
172.25.16.1 weight=3;
server
172.25.16.2 weight=1;
}
//虚拟主机的配置
server
{
listen
80;
server_name
localhost;
//域名可以有多个,用空格隔开
//默认请求
location / {
root
html;
//定义服务器默认访问站点目录
index index.html
index.html; //索引文件的名称
}
//定义错误提示页面
error_page 500 502 503
504 /50x.html;
location = /50x.html {
root html;
}
//对php后缀结尾的文件请求采用负载均衡请求
location ~ \.php$ {
proxy_pass
westos;
//将请求转向westos定义的服务器列表
}
//php脚本请求全部处理转发到FastCGI处理
location ~ \.php$ {
root
html;
fastcgi_pass
127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
/scripts$fastcgi_script_name;
include
fastcgi_params;
}
//禁止访问.htxx文件
location ~ /\.ht {
deny all;
}
}
相关文章推荐
- 小心服务器内存居高不下的元凶--WebAPI服务
- 运维入门
- Linux5.9无人值守安装
- 数据中心和云未来的十二大趋势
- 用vsftp快速搭建ftp服务器
- Linux快速构建apache web服务器
- 服务器监控策略浅谈
- 如何降低服务器采购成本 原理分析
- 建议的服务器分区办法
- 服务器托管六大优势分析
- Erlang实现的一个Web服务器代码实例
- 服务器技术全面解析
- Ruby中require、load、include、extend的区别介绍
- 保护DNS服务器的几点方法小结
- 我国成为全球第二大服务器消费国
- 服务器 安全检查要点[星外提供]
- 服务器应用自动重新启动IIS批处理[原创]_DOS/BAT_脚本之家
- FTP 服务器关于权限的问题
- 批处理设置windows服务器的代码ThecSafe1.9.4第1/3页