nginx -无法重新启动进程

3ks5zfa0  于 2022-11-21  发布在  Nginx
关注(0)|答案(1)|浏览(245)

使用nginx -t测试时,我的配置中没有错误

root@proxy1:/var/www# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

然而,当我尝试运行systemctl restart nginx时,我得到以下错误。

root@proxy1:/var/www# 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.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 Sun 2022-10-09 19:43:09 CEST; 48s ago
       Docs: man:nginx(8)
    Process: 1439643 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 1439658 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)

Oct 09 19:43:08 SERVERHOSTNAME.net nginx[1439658]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Oct 09 19:43:09 SERVERHOSTNAME.net nginx[1439658]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Oct 09 19:43:09 SERVERHOSTNAME.net nginx[1439658]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Oct 09 19:43:09 SERVERHOSTNAME.net nginx[1439658]: nginx: [emerg] bind() to 0.0.0.0:3582 failed (98: Address already in use)
Oct 09 19:43:09 SERVERHOSTNAME.net nginx[1439658]: nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
Oct 09 19:43:09 SERVERHOSTNAME.net nginx[1439658]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Oct 09 19:43:09 SERVERHOSTNAME.net nginx[1439658]: nginx: [emerg] still could not bind()
Oct 09 19:43:09 SERVERHOSTNAME.net systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Oct 09 19:43:09 SERVERHOSTNAME.net systemd[1]: nginx.service: Failed with result 'exit-code'.
Oct 09 19:43:09 SERVERHOSTNAME.net systemd[1]: Failed to start A high performance web server and a reverse proxy server.

然而,我所有的网站运行在nginx的功能。
我在运行certbot时也会遇到与此相关的问题。

root@proxy1:/var/www# certbot
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx

...

Obtaining a new certificate
Performing the following challenges:
http-01 challenge for MYDOMAIN.net
nginx: [error] invalid PID number "" in "/run/nginx.pid"
Cleaning up challenges
nginx: [error] invalid PID number "" in "/run/nginx.pid"

nginx restart failed:
b''
b''
juud5qan

juud5qan1#

我不确定这是否是Nginx的一个bug,但你可以试试这个(对我来说很有效):

pkill -9 nginx
nginx -c /etc/nginx/nginx.conf
nginx -s reload

Source

相关问题