在nginx.exe目录,打开命令行工具,用命令 启动/关闭/重启nginx (如nginx找不到 ./nginx)
start nginx : 启动nginx
nginx -s reload :修改配置后重新加载生效
nginx -s reopen :重新打开日志文件
nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确
关闭nginx:
nginx -s stop :快速停止nginx
nginx -s quit :完整有序的停止nginx
如果遇到报错:
bash: nginx: command not found
有可能是你再linux命令行环境下运行了windows命令,
如果你之前是允许 nginx -s reload报错, 试下 ./nginx -s reload
或者 用windows系统自带命令行工具运行
nginx 配置
worker_processes 1;
events {
#允许的连接数
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
# 代理静态页面
root E:/rjhc/block_chain_management/dist;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# 代理接口
location /v1/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080/;
}
}
}