當我們使用systemctl restart nginx 命令重啟服務時發現報錯如下:
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
首先我們可以用 systemctl status nginx 查看當前nginx狀態
systemctl status nginx
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2021-08-06 15:04:33 CST; 4min 10s ago
Docs: http://nginx.org/en/docs/
Process: 2099 ExecStop=/bin/sh -c /bin/kill -s TERM $(/bin/cat /var/run/nginx.pid) (code=exited, status=0/SUCCESS)
Process: 2131 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE)
Main PID: 1498 (code=exited, status=0/SUCCESS)
Aug 06 15:04:33 localhost.localdomain systemd[1]: Starting nginx - high performance web s.....
Aug 06 15:04:33 localhost.localdomain nginx[2131]: nginx: [warn] the "ssl" directive is d...:5
Aug 06 15:04:33 localhost.localdomain nginx[2131]: nginx: [emerg] cannot load certificate...e)
Aug 06 15:04:33 localhost.localdomain systemd[1]: nginx.service: control process exited, ...=1
Aug 06 15:04:33 localhost.localdomain systemd[1]: Failed to start nginx - high performanc...r.
Aug 06 15:04:33 localhost.localdomain systemd[1]: Unit nginx.service entered failed state.
Aug 06 15:04:33 localhost.localdomain systemd[1]: nginx.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
第一種方法: 我們發現埠被占用,使用命令查看被占用埠的行程:netstat -anltp | grep 80
查看到被占用的行程號 然后 kill -9 行程號 殺死行程之后繼續重啟
第二種方法:可能是我們在修改/etc/nginx/conf.d/default.conf或者是/etc/nginx/nginx.conf檔案時配置錯誤 ,重新檢查編輯,如果實在找不到錯誤,我們可以進入nginx的報錯日志進行查看:tail -f /var/log/nginx/error.log 根據nginx的報錯檔案可以進行相關的具體修改.
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/292305.html
標籤:其他
