Centos7 配置systemctl的Nginx啟動服務,start一直卡着,stop不生效


問題:Centos7 配置systemctl的Nginx啟動服務,start一直卡着,stop不生效

發現以下問題

  • 啟動Nginx時一直卡着不動在 Starting nginx (via systemctl):

    • 實際端口是開啟了

    • 必須通過Ctrl + C強制關閉

  • 關閉Nginx時,提示成功,但是端口沒關閉

查看Nginx 狀態日志如下

[root@xxx nginx-1.17.2]# systemctl status nginx
● nginx.service - SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server
Loaded: loaded (/etc/rc.d/init.d/nginx; bad; vendor preset: disabled)
Active: inactive (dead) since Thu 2019-08-08 05:37:04 EDT; 2min 15s ago
Docs: man:systemd-sysv-generator(8)
CGroup: /system.slice/nginx.service
├─21402 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
└─21403 nginx: worker process

Aug 08 05:36:50 10-0-94-90 systemd[1]: Starting SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server...
Aug 08 05:36:50 10-0-94-90 nginx[21393]: Starting nginx: [ OK ]
Aug 08 05:36:50 10-0-94-90 systemd[1]: PID file /usr/local/nginx/logs/nginx.pid not readable (yet?) after start.
Aug 08 05:37:04 10-0-94-90 systemd[1]: Stopped SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server.

如上PID文件位置不對,修改PID文件路徑即可解決上面問題

解決:修改/etc/init.d/nginx 配置的PID文件路徑和nginx.conf文件中的PID路徑一致


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM