微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在Ubuntu 15.04和15.10上使用systemd启动时,nginx无法启动

Nginx不会在启动时启动,而是手动启动.日志说的像
Nginx: [emerg] host not found in upstream "{some hostname}" in /etc/Nginx/conf.d/some_site.conf
Nginx: configuration file /etc/Nginx/Nginx.conf test Failed

Failed to start A high performance web server and a reverse proxy server.
Nginx.service: Unit entered Failed state.
Nginx.service: Failed with result 'exit-code'.

似乎在启动时dns尚未就绪,Nginx正在尝试查找我作为反向代理的主机名.

经过一些研究后发现systemd使用下面的文件来启动Nginx
/lib/systemd/system/Nginx.service

Ubuntu 15.04,Ubuntu 15.10上的文件,甚至Nginx网站本身都说要使用After行,如下所示

After=network.target

这使得一个人认为网络应该已经准备好了.但是,我找到了链接http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/

network.target has very little meaning during start-up. It only indicates that the network management stack is up after it has been reached.

这个链接继续说

network-online.target is a target that actively waits until the nework is “up”,where the deFinition of “up” is defined by the network management software.

所以我改变了After的用法

After=network-online.target

现在Nginx在启动时启动良好.我没有声称这是完全正确的解决方案,因为有可能使用不同的After目标,这在某些其他方面会更正确,但这似乎适用于最后几次重新启动.

原文地址:https://www.jb51.cc/ubuntu/348418.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐