• Nginx引用多配置文件


    在nginx.conf的http模块,include 指定某个目录下的*.conf

    user nginx;
    worker_processes auto;
    error_log /var/log/nginx/error.log;
    pid /run/nginx.pid;
    
    # Load dynamic modules. See /usr/share/nginx/README.dynamic.
    include /usr/share/nginx/modules/*.conf;
    
    events {
        worker_connections 1024;
    }
    
    http {
        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;
        tcp_nodelay         on;
        keepalive_timeout   65;
        types_hash_max_size 2048;
    
        include             /etc/nginx/mime.types;
        default_type        application/octet-stream;
    
        # Load modular configuration files from the /etc/nginx/conf.d directory.
        # See http://nginx.org/en/docs/ngx_core_module.html#include
        # for more information.
        include /etc/nginx/conf.d/*.conf;
        server {
            listen       8080 default_server;
            listen       [::]:8080 default_server;
            server_name  _;
            root         /usr/share/nginx/html;
    
            # Load configuration files for the default server block.
            include /etc/nginx/default.d/*.conf;
    
            location / {
            }
    
            error_page 404 /404.html;
                location = /40x.html {
            }
    
            error_page 500 502 503 504 /50x.html;
                location = /50x.html {
            }
        }
        include             sites-enabled/*.conf;
    }

    创建sites-enabled目录,编写配置文件

    mkdir /etc/nginx/sites-enabled
    touch /etc/nginx/sites-enabled/test1.conf

    编写sever模块创建多个虚拟主机(注意root目录及日志文件路径)

  • 相关阅读:
    141. Linked List Cycle
    2. Add Two Numbers
    234. Palindrome Linked List
    817. Linked List Components
    《算法图解》之快速排序
    C++-对象指针的滥用
    C++学习书籍评价
    C++-随机数的产生
    Java-重载和重写区别剖析
    Qt- 图形界面应用程序的运行模式
  • 原文地址:https://www.cnblogs.com/Xinenhui/p/15793382.html
Copyright © 2020-2023  润新知