gpt4 book ai didi

ubuntu - 重启 NGINX 失败

转载 作者:行者123 更新时间:2023-12-04 18:40:51 35 4
gpt4 key购买 nike

我在 Ubuntu 16.04 上安装了 NGINX 并编辑了我的配置。
当我想用 sudo service nginx restart 重新启动时我得到错误:

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



nginx.service status 的内容是:
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 Mon 2017-01-02 16:07:54 UTC; 15s ago
Process: 26515 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Process: 26510 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 3464 (code=exited, status=0/SUCCESS)

Jan 02 16:07:53 IF-STG-001 nginx[26515]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Jan 02 16:07:53 IF-STG-001 nginx[26515]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jan 02 16:07:53 IF-STG-001 nginx[26515]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Jan 02 16:07:54 IF-STG-001 nginx[26515]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jan 02 16:07:54 IF-STG-001 nginx[26515]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Jan 02 16:07:54 IF-STG-001 nginx[26515]: nginx: [emerg] still could not bind()
Jan 02 16:07:54 IF-STG-001 systemd[1]: nginx.service: Control process exited, code=exited status=1
Jan 02 16:07:54 IF-STG-001 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Jan 02 16:07:54 IF-STG-001 systemd[1]: nginx.service: Unit entered failed state.
Jan 02 16:07:54 IF-STG-001 systemd[1]: nginx.service: Failed with result 'exit-code'.

为什么我不能重启我的 nginx 实例?我不明白为什么它会阻止重启

最佳答案

错误消息的重要部分是

bind() to 0.0.0.0:80 failed (98: Address already in use)



因此,在启动时,nginx 无法绑定(bind)到端口 80,因为其他一些程序已经绑定(bind)到该端口。只有当这个其他程序退出或从这个套接字解除绑定(bind)时,你才能启动 nginx。

要查找当前绑定(bind)此端口的程序,您可以以 root 身份运行此命令(例如,使用 sudo ):
ss -ntlp "sport = :80"

关于ubuntu - 重启 NGINX 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41430008/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com