# 此文件在nginx.conf文件中被引入 # 定义一个HTTP服务器块,监听80端口,并且同时监听IPv4和IPv6地址的80端口 server { listen 80; listen [::]:80; # 服务器名为localhost,即请求的域名为localhost时,会使用该server块的配置 server_name www.yang-dev.top; charset 'utf-8'; #防止txt文本出现乱码,一定要加单引号 # 注释掉以下access_log配置,表示不记录访问日志 #access_log /var/log/nginx/host.access.log main; location ~* \.(txt|c|cpp|java|py|sh|h|pro|props|yam|yaml|xml|ini|js|css|md)$ { root /usr/share/nginx/html/yang; charset 'utf-8'; } # 配置根目录和默认的索引文件 location / { root /usr/share/nginx/html/yang; #add_header Content-Type text/plain; index index.html index.htm; } location /personal { alias /usr/share/nginx/html/yang/personal; autoindex on; autoindex_exact_size off; autoindex_localtime on; } location /stacks { alias /usr/share/nginx/html/yang/stacks; autoindex on; autoindex_exact_size off; autoindex_localtime on; } location /test { alias /usr/share/nginx/html/yang-vue/test/; index index.html; } location /vue { root /usr/share/nginx/html/yang-vue; index index.html; } location /webpack { root /usr/share/nginx/html; index index.html; } # 注释掉以下error_page配置,表示不自定义错误页 #error_page 404 /404.html; # 配置5xx错误码的错误页 # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # 注释掉以下配置,表示不使用代理将PHP脚本传递给Apache服务器 # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # 配置FastCGI服务器,将PHP脚本传递给监听在127.0.0.1:9000的FastCGI服务器 # 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; #} # 注释掉以下配置,表示禁止访问.htaccess文件 # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } #server { # listen 80; # listen [::]:80; # # 服务器名为localhost,即请求的域名为localhost时,会使用该server块的配置 # server_name www.yang-dev.top; # # # 注释掉以下access_log配置,表示不记录访问日志 # #access_log /var/log/nginx/host.access.log main; # # # 配置根目录和默认的索引文件 # location /test { # alias /usr/share/nginx/html/yang-vue/test/; # index index.html; # } # # # 注释掉以下error_page配置,表示不自定义错误页 # #error_page 404 /404.html; # # # 配置5xx错误码的错误页 # # redirect server error pages to the static page /50x.html # # # error_page 500 502 503 504 /50x.html; # location = /50x.html { # root /usr/share/nginx/html; # } # #}