nginx主(子)配置文件参考

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

user  nginx;
worker_processes  1;
error_log  /var/log/nginx/nginx_error.log;
pid        /usr/local/nginx/run/nginx.pid;

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"';
    include       mime.types;
    default_type  application/octet-stream;
    access_log  /var/log/nginx/nginx_access.log  main;
    sendfile        on;
    tcp_nopush     on;
    keepalive_timeout  65;
    gzip  on;
    include /etc/nginx/conf.d/*.conf;
}

子配置文件/etc/nginx/conf.d/test.conf

server {
    listen       80;
    server_name  www.test.com;
    access_log  /var/log/nginx/test-access.log  main;
    error_log   /var/log/nginx/test-error.log;
    location / {
        root   /var/www/html;
        index  index.html index.htm;
    }
}

配置若有遗漏或错误,请评论留言。
原文地址:https://www.cnblogs.com/BrokenEaves/p/15145666.html