美文网首页
Nginx-nginx.conf解读

Nginx-nginx.conf解读

作者: ssttIsme | 来源:发表于2023-04-21 16:35 被阅读0次

#是注释,不生效的内容

user  nobody

nginx启动的时候用什么用户

events

是事件驱动模块

worker_processes

工作进程的个数,一个cpu内核对应一个worker_processes

 worker_connections  1024;

每个worker进程默认创建1024个连接

include       mime.types;

mime.types记录了请求头返回或者发送的文件是什么类型的,比如文本文档或者html文档,可执行应用程序,flush文件,由服务端向客户端浏览器发送一个头来明确告诉他自己发送的是什么文件。

 sendfile        on;

数据0拷贝(应用程序不加载磁盘文件),减少数据调度过程

keepalive_timeout  65;

保持连接超时的时间

server 就是一个虚拟主机,可以配置多个虚拟主机,每个主机互相不干扰,可以通过端口号的方式区分每个主机的不同
server_name可以配置域名或主机名
location是uri(资源)或者uri的一部分,通过这个找root目录
root是当前目录匹配上location后从哪个目录找网页
html是相对nginx程序主目录如/usr/local/nginx/html

error_page   500 502 503 504  /50x.html;

发生服务器端错误时跳转到当前站点的50x.html


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    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$ {
        #    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;
    #    server_name  localhost;

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

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;

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

}

相关文章

  • 女娲文化之研究

    古代传说解读篇 道家文化解读篇 东西方文化对照解读篇 瑜伽能量解读篇 佛家文化解读篇 封神演义解读篇 现代解读意义篇

  • 破界突围之路:初探IPD流程(三)

    继上篇,IPD流程的源头,要通过三解读(标准解读、客户需求解读、场景解读),充分解读需求,再去适配产品,进入产品...

  • 不同的人学习同一个知识的分解和解读是不同的

    今天跟天赋解读师颜姐了解天赋解读,其实原先已经有另一个天赋解读师给解读过我自己的天赋。 上次的天赋解读师,只是解读...

  • 《把时间当做朋友》快读完了,记录今日份感受

    李笑来用最没有偏差的视角去解读自己,解读他人,解读生活,解读社会,解读世界。通过他的“时间”让我看到了正确...

  • 解读

    解读你 解读你的思想 解读你的一切 解读你不需要和时间赛跑 只要和你有过交谈、旅行、舞会, 就会知道“你” 解读你...

  • 【猜你喜欢】手淘流量,猜你喜欢行业案例解读

    猜你喜欢行业案例解读 目录: <女装行业案例解读1> 《女装行业案例解读2》 <美妆行业案例解读> <女装行业案例...

  • 书籍《原则》解读

    原则解读 1 拥抱现实,应对现实--“原则解读” (1) 心态+游戏化思维--原则解读(2)

  • 【Java源码计划】LongAdder<rt.jar_ja

    LongAdder 源码解读 源码解读部分按照我得理解翻译和解读注解并添加相关的部分代码解读 保持一个或者多个变量...

  • 领悟

    为什么解读文本困难?因为没有解读工具。为什么没有解读工具?因为读的书太少。怎样才可以拥有解读工具?读相关的理论书籍...

  • 对文章被锁定的疑问

    本人所写文章属于名著解读类,内容包括两部分,引用《金瓶梅》原文和本人解读。既为解读,引用原文必不可少,解读部分皆为...

网友评论

      本文标题:Nginx-nginx.conf解读

      本文链接:https://www.haomeiwen.com/subject/skkjjdtx.html