码迷,mamicode.com
首页 > 其他好文 > 详细

nginx学习:配置文件及其组成

时间:2020-04-25 20:49:08      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:端口   connect   mic   style   error   表达式   eve   live   form   

一:配置文件

etc是linux系统放置核心配置的文件夹

/etc/logrotate.d/nginx 配置文件 用于nginx日志轮转,logrotate服务的日志切割

/etc/nginx  目录配置文件  nginx的主要配置文件

/etc/nginx/nginx.conf 主要配置文件  nginx启动会读取的配置文件

/etc/nginx/conf.d 主要配置文件

/etc/nginx/conf.d/default/conf 主要配置文件  默认安装好之后,server加载读取的配置文件

 

/etc/nginx/nginx.conf

技术图片

vim nginx,conf

user  nginx;

第一部分:全局块 配置运行nginx服务器组,允许产生worker process数,进程pid存放路径、日志存放路径以及配置文件的引入 worker_processes
1; # nginx服务器并发处理服务的关键配置,值越大,可以支持并发处理量就越多,但是会受到硬件、软件等设备的制约 error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid;

第二部分:events块:主要影响nginx服务器与用户的网络连接,常用的设置包括是否开启很多对worker process下的网络连接进行序列化,是否允许同时接受多个网络请求,选取那种事件驱动模型来处理请求,
每个worker process可以同时支持的最大连接数等。1024表示最大连接数位1024个,这部分的配置对nginx的性能影响较大,在实际中应该灵活配置。 events { worker_connections
1024; }

第三部分:http块:nginx配置里面配置最频繁的部分,代理、缓存和日志等绝大多数功能和第三方模块的配置都在这里。http块包括了:http全局块server块 http全局块 http { include
/etc/nginx/mime.types; default_type application/octet-stream; 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 /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on;

server块
默认的文件里面没有
nginx version: nginx/1.16.1 猜测这个版本里面需要自己配置

    include /etc/nginx/conf.d/*.conf;
}

 

从网上找到了 1.16.1版本别人conf里面配置的server块代码

    server {
        listen       80;  # 监听端口号
        server_name  localhost; # 主机名称
 
        #charset koi8-r;
 
        #access_log  logs/host.access.log  main;
        # 请求跳转等
        location / {
            root   html;
            index  index.html index.htm;
        }
 
        #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$ {  # 类似于正则表达式,url以\.php结尾的都跳转到 http://127.0.0.1上面
        #    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;
        #}
原文链接:https://blog.csdn.net/londa/article/details/91365197

 

 

 

 

 

 

 

 

# TODO

 

nginx学习:配置文件及其组成

标签:端口   connect   mic   style   error   表达式   eve   live   form   

原文地址:https://www.cnblogs.com/meloncodezhang/p/12775137.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!