Centos7下nginx启动提示Can't open PID file /var/run/nginx.pid

作者: 来源:本站原创 点击数: 发布时间:2022年09月14日

错误截图如下:

796be99b660d46cf93d1bd803442a3ac.png

1.nginx -V;查看默认的PID路径;并检查该路径下是否存在nginx.pid文件;


b61b40185e634e5abb4fd4c5674e4f1a.png

2.找到/usr/lib/systemd/system/nginx.service;修改PIDFile=/etc/nginx/logs/nginx.pid


a091a3a89a8441bcb4f88468c75223d7.png

3.vim /usr/lib/systemd/system/nginx.service;


6059b9456aaf4e67bb5f59b85eea9686.png

4.vim /etc/nginx/nginx.conf;添加pid    /etc/nginx/logs/nginx.pid ;

5.sudo systemctl daemon-reload

   nginx -s reload

6.重新启动nginx即可 systemctl restart nginx

c728cad1557042d89d88b40d2313b582.png