systemctl启动nginx失败

systemctl启动nginx失败

免责声明:我没有任何服务器管理经验,所以请原谅我的用词不当以及描述问题时明显缺乏努力。我只是真的不知道自己在做什么。

无论如何,我一直在关注本文自动生成 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老实说,我什至不知道那是什么。我相信这是某种服务接口,但我真的不知道。它是在设置临时服务器时刚刚安装的。

答案1

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

意味着仍然有一个正在运行的守护进程正在侦听端口 80。您可以使用

lsof -i :80

找出它是什么。停止它,然后您就可以启动该nginx服务了。

相关内容