linux下的nginx.conf文件内容详解


#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;
        }

    }

}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值