(3)nginx 配置(nginx.conf)

nginx 配置文件默认在安装目录的 conf/ 目录下,主配置文件则为 /usr/local/nginx/conf/nginx.conf

# 使用的用户和组; user  root root
user  nobody;

# 指定工作进程数,一般为CPU总核数,或总核数的两倍,语法: worker_processes number | auto;
worker_processes  1;

# 错误日志路径, 日志记录级别:[ debug | info | notice | warn | error | crit]
error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

# 指定pid文件存储路径
#pid        logs/nginx.pid;

# 指定进程能够打开的最大文件描述符数量,最好小于等于系统软限制
worker_rlimit_nofile  1024;

# 
events {
    # 使用的网络I/O模型, select、poll、epoll(Linux推荐使用)、kqueue(FreeBSD 推荐使用)
    use epoll;

    # 允许的连接数,不能大于OS支持的最大句柄数
    worker_connections  1024;

    # 设置网络链接序列化,语法:  accept_mutex on | off;  开启时会对进程接受连接序列化,防止多个进程对连接产生争抢(惊群)
    #accept_mutex on;

    # 设置是否允许worker进程同时接受多个网络连接,语法: multi_accept on | off; ,关闭即每次只能接受一个连接
    #multi_accept on;
}


http {
    # 
    include       mime.types;
    default_type  application/octet-stream;

    # 设置使用的字符集,若有多种字符集,应该让程序员在HTML中通过Meta标签设置
    #charset  gb2312
    
    # 日志格式设置  
    #    $remote_addr 客户端IP地址
    #    $remote_user 客户端用户名称
    #    $time_local  访问时间与时区
    #    $request     记录请求的url与协议
    #    $status      请求状态
    #    $body_bytes_sent    记录请求主体内容大小
    #    $http_referer    记录从哪个链接访问过来
    #    $http_user_agent 客户端浏览器相关信息
    #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()传输文件,可在http\server\location块进行设置
    sendfile        on;
    
    # 设置传输文件的最大值,默认为0, 即无限制,可在http\server\location块进行设置
    #sendfile_max_chunk  size;

    #tcp_nopush     on;

    # 保活时间, 语法: keepalive_timeout  timeout  [header_timeout]
    # timeout        服务器对连接的保持时间
    # header_timeout 应答报文的超时时间
    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    # 每个server块代表一个虚拟主机
    server {

        # 网络监听,三种:1、监听IP: listen address[:port] [default_server] [setfib=number] [backlog=number] [rcvbuf=size] [sndbuf=size] [deferred] [accept_filter=filter] [bind] [ssl]; 
        # 2、监听端口: listen port [default_server] [setfib=number] [backlog=number] [rcvbuf=size] [sndbuf=size] [deferred] [accept_filter=filter] [bind] [ipv6only=on | off] [ssl]; 
        # 3、 UNIX Domain Socket
        # backlog=number 设置最多允许多少网络连接同时处于挂起状态
        # rcvbuf=size    设置监听socket接受缓冲区大小
        # deferred     表示符,将accept() 设置为Deferred模式
        listen       80;

        # 即域名,可以有多个,并排空格分开,还可以使用正则表达式,“~”作为正则的开始标记
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        # 
        location / {
            # 配置请求的根目录
            root   html;
            index  index.html index.htm;
        }

        #限制用户通过某一连接向nginx服务器发送连接的次数, 该指令可出现在server、location块
        #keepalive_requests  number;

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #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;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值