windows下可使用此基础配置
#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_names_hash_bucket_size 64;
proxy_buffer_size 128k; # default: 4k|8k
proxy_buffering on; # default: on
proxy_buffers 64 64k; # default: 8 4k|8k
proxy_busy_buffers_size 256k; # default: 8k|16k
proxy_max_temp_file_size 1024m; # default: 1024m
proxy_temp_file_write_size 256k; # default: 8k|16k
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
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;
}
}
server {
listen 80;
server_name xxx.com;
return 301 http://www.xxx.com$request_uri;
}
server {
listen 80;
server_name www.xxx.com;
location /*.ico {
root path; #文件路径:C:/web/xxx
}
location / {
root path; #文件路径:C:/web/xxx
try_files $uri $uri/ /index.html;
}
location /view/ {
root path; #文件路径:C:/web/xxx
rewrite .* /index.html break;
}
}
}
使用cmd进入nginx所在目录后常用命令:
查看Nginx的版本号:nginx -V
启动Nginx:start nginx
快速停止或关闭Nginx:nginx -s stop
正常停止或关闭Nginx:nginx -s quit
配置文件修改重装载命令:nginx -s reload