Symfony
我在服务器上运行一个网站,使用Nginx
配置Let's Encrypt
。当我启动服务器时一切正常(总是使用sudo service nginx start
/ restart
)
但每三个月我就会发现网站瘫痪了。当我检查日志时,总是同样的情况:
2018/12/23 00:23:53 [notice] 22167#22167: signal process started
2018/12/23 00:23:53 [error] 22167#22167: open() "/run/nginx.pid" failed (2: No such file or directory)
2018/12/23 00:23:54 [emerg] 22194#22194: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/23 00:23:54 [emerg] 22194#22194: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/23 00:23:54 [emerg] 22194#22194: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/23 00:23:54 [emerg] 22194#22194: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/23 00:23:54 [emerg] 22194#22194: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/23 00:23:54 [emerg] 22194#22194: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/23 00:23:54 [emerg] 22194#22194: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/23 00:23:54 [emerg] 22194#22194: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/23 00:23:54 [emerg] 22194#22194: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/23 00:23:54 [emerg] 22194#22194: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/23 00:23:54 [emerg] 22194#22194: still could not bind()
2018/12/23 00:23:57 [alert] 22169#22169: unlink() "/run/nginx.pid" failed (2: No such file or directory)
我知道其他人也遇到过同样的问题,但都是在启动时。对我来说,后来有事触发了它...
还 :
uname -a
Linux vps460780 4.9.0-7-amd64 #1 SMP Debian 4.9.110-3+deb9u2 (2018-08-13) x86_64 GNU/Linux
运行 nginx 时:
sudo netstat -tulpn | grep :443
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 6644/nginx: master
sudo netstat -tulpn | grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 7021/nginx: master
我很乐意发布任何其他配置文件。
答案1
你的 Let's Encrypt 帖子钩子应该重新加载nginx,不是重新开始它,即:
--post-hook "systemctl reload nginx"
要摆脱当前情况,请终止所有现有的 nginx 进程,然后重新启动 nginx,即:
killall nginx
systemctl restart nginx
答案2
我遇到过同样的问题,我发现我还有另一个 cron 作业正在运行(以 root 身份)certbot renew --post-hook="systemctl reload nginx"
。我想我之前已经按照教程安装了它,它告诉我添加这个 cron 条目,但从那时起事情发生了变化,它会自行安装。
仍然需要验证这是否能修复它(等待数月看看是否发生)但我怀疑就是这样。