Nginx

systemctl 啟動 nginx 失敗

  • June 19, 2020

免責聲明:我的伺服器管理經驗為 0,因此請原諒我的術語以及在描述問題時明顯缺乏努力。我只是不知道我在做什麼。

無論如何,我一直在關注這篇文章來自動生成 SSL 證書,這是我們任意域所需要的東西,這導致我到這些文件來安裝正是這樣做的 nginx 擴展。我開始瀏覽需求部分並繼續安裝第一個:OpenResty,我相信它擴展了 nginx 模組。我遵循安裝過程,執行初始命令以關閉 nginx 以進行安裝:

sudo systemctl disable nginx
sudo systemctl stop nginx

安裝很順利,但是當我嘗試再次啟動 nginx 時

sudo systemctl enable nginx
sudo systemctl start nginx

我在最後一個命令中收到錯誤:

Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

這就是sudo systemctl status nginx.service告訴你:

● nginx.service - A high performance web server and a reverse proxy server
  Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
  Active: failed (Result: exit-code) since Fri 2020-06-19 11:50:25 UTC; 5min ago
 Process: 2160 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
 Process: 2157 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)

Jun 19 11:50:22 staging nginx[2160]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jun 19 11:50:23 staging nginx[2160]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jun 19 11:50:23 staging nginx[2160]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jun 19 11:50:24 staging nginx[2160]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jun 19 11:50:24 staging nginx[2160]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jun 19 11:50:25 staging nginx[2160]: nginx: [emerg] still could not bind()
Jun 19 11:50:25 staging systemd[1]: nginx.service: Control process exited, code=exited status=1
Jun 19 11:50:25 staging systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Jun 19 11:50:25 staging systemd[1]: nginx.service: Unit entered failed state.
Jun 19 11:50:25 staging systemd[1]: nginx.service: Failed with result 'exit-code'.

我不知道這意味著什麼或如何解決它。systemctl老實說,我什至不知道是什麼。我相信它是某種服務介面,但我真的不知道。它只是在設置登台伺服器時安裝的。

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

表示在埠 80 上仍有一個正在執行的守護程序。您可以使用

lsof -i :80

找出它是什麼。停止它,然後您將能夠啟動該nginx服務。

引用自:https://unix.stackexchange.com/questions/593813