服务器上有多个nginx,定位当前正在运行的Nginx的配置文件html
ps -ef | grep nginx #查看当前运行的nginx的位置 #1,查看nginx的PID,以经常使用的80端口为例: netstat -anop | grep 0.0.0.0:80 #2,经过相应的进程ID(好比:4562)查询当前运行的nginx路径: ll /proc/4562/exe #3. 获取到nginx的执行路径后,使用-t参数便可获取该进程对应的配置文件路径 /usr/local/nginx/sbin/nginx -t #输出如下 nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
linux nginx启动 重启 关闭命令:vue
如下命令均要在响应目录下运行或者全路径下
home/odin/nginx/sbin/nginx -s reload #修改配置后从新加载生效
# 启动操做 要启动的nginx 的sbin目录下 ./nginx -s reload #修改配置后从新加载生效 #启动操做 -c参数指定了要加载的nginx配置文件路径 ./nginx -c /usr/local/nginx/conf/nginx.conf #从新打开日志文件 ./nginx -s reopen #测试nginx配置文件是否正确 ./nginx -t -c /path/to/nginx.conf #中止nginx nginx -s stop #快速中止nginx quit #完整有序的中止nginx #其余的中止nginx 方式:找到进程发送信号方式 #步骤1,查询nginx主进程号 ps -ef | grep nginx #步骤2:发送信号 kill -QUIT 16391 #从容中止Nginx: kill -TERM 16391 #快速中止Nginx: kill -9 16391 #强制中止Nginx:
worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #vhost文件夹下的多端口配置 include ./vhost/*.conf; sendfile on; server { listen 8088; server_name localhost; location / { root D:\WuWorkSpace\wu_project\wu_vueProject\mySGMpro\feature_v2_9_0dist;#文件目录 try_files $uri $uri/ @router; #须要指向下面的@router不然会出现vue的路由在nginx中刷新出现404 index index.html;#默认起始页 } #对应上面的@router,主要缘由是路由的路径资源并非一个真实的路径,因此没法找到具体的文件 #所以须要rewrite到index.html中,而后交给路由在处理请求资源 location @router { rewrite ^.*$ /index.html last; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } #location ~ /\. #{ # deny all; #} } }