#user nobody nginx启动的所属用户,默认为nobody;
# nginx的最大worker的最大进程数 建议设置为当前服务器的CPU核数
worker_processes 1;
# 错误日志的日志级别 , 错误日志的路径位置
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid的路径位置
#pid logs/nginx.pid;
events {
#单个进程最大连接数
worker_connections 1024;
}
#设定http服务器,利用它的反向代理功能提供负载均衡支持
http {
#文件扩展名与文件类型映射表
include mime.types;
# 默认的类型
default_type application/octet-stream;
# access.log日志的格式设置,默认为下面的格式
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access.og文件配置
#access_log logs/access.log main;
#开启高效文件传输模式,sendfile指令指定nginx是否调用sendfile函数来输出文件,对于普通应用 设为 on,如果用来进行下载等应用磁盘IO重负载应用,可设置为off,以平衡磁盘与网络I/O处理速度,降低系统的负载。注意:如果图片显示不正常把这个改成off。
sendfile on;
#此选项允许或禁止使用socke的TCP_CORK的选项,此选项仅在使用sendfile的时候使用
#tcp_nopush on;
#长连接超时时间,单位是秒
#keepalive_timeout 0;
keepalive_timeout 65;
# 开启压缩输出,压缩数据使得数据传输更快
#gzip on;
#虚拟主机的配置
server {
#监听的端口,默认为80
listen 80;
#域名可以有多个,用空格隔开
server_name localhost;
#charset koi8-r;
#定义本虚拟主机的访问日志
#access_log logs/host.access.log main;
#对"/"请求路径进行代理
location / {
#root表示根目录 , html表示根目录下的html文件夹
root html;
#被访问的文件
index index.html index.htm;
}
# 错误页面
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}