首页 Nginx网站架设(一服多站)

配置文件


路径:D:\nginx-1.25.2\conf\nginx.conf

原始文件注解


#user nobody;  #指定可运行Nginx的用户,windows下无效
worker_processes 1;  #进程数量,整数、auto自动设置

#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;  #默认配置类型,不设置默认值是"text/plain"

  #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;           #端口,外网浏览器默认访问端口是80,所以不用改
    server_name localhost;  #域名,修改"localhost",如"www.liboke.cn"

    charset      utf-8;     #HTML使用编码设置

    #access_log logs/host.access.log main;

    location / {  ###可设多个,每个解析不同的请求url###
      root  html;  #指定HTML文件目录,从根目录解析
      index index.html index.htm;  #首页文件定义
    }

    #error_page 404       /404.html;

    # 将服务器错误页面重定向到静态页面/50x.html
    error_page  500 502 503 504 /50x.html;
    location = /50x.html {
      root  html;
    }

    # 将PHP脚本代理到127.0.0.1:80上的Apache侦听
    #location ~ \.php$ {
    #  proxy_pass  http://127.0.0.1;
    #}

    # 将PHP脚本传递到侦听127.0.0.1:9000的FastCGI服务器
    #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;
    #}

    # 如果Apache的文档根目录与nginx的一致
    #location ~ /\.ht {
    #  deny all;
    #}
  }

  
  # 使用基于IP、名称和端口的混合配置的另一个虚拟主机
  #server {
  #  listen    8000;
  #  listen    somename:8080;
  #  server_name somename alias another.alias;
  #  charset      utf-8;
  #  location / {
  #    root  html;
  #    index index.html index.htm;
  #  }
  #}


  # HTTPS服务器
  #server {
  #  listen    443 ssl;      #端口,https使用端口443,不改
  #  server_name localhost;  #域名,修改"localhost",如"www.liboke.cn"

  #  ssl_certificate   cert.pem;   #SSL文件路径设置
  #  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;

  #  charset      utf-8;

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

}