![nginx 开机启动失败,但之后启动良好](https://linux22.com/image/153148/nginx%20%E5%BC%80%E6%9C%BA%E5%90%AF%E5%8A%A8%E5%A4%B1%E8%B4%A5%EF%BC%8C%E4%BD%86%E4%B9%8B%E5%90%8E%E5%90%AF%E5%8A%A8%E8%89%AF%E5%A5%BD.png)
在 Archlinux 上,我正在运行一个nginx
由systemd
.该nginx
单元已启用,systemd
因此它应该在启动时启动。
但每次重启后,都无法启动,并出现以下错误:
➜ ~ journalctl -f -u nginx
-- Logs begin at Wed 2017-09-20 22:14:25 CEST. --
May 06 12:58:58 vps458278 systemd[1]: Starting A high performance web server and a reverse proxy server...
May 06 13:00:29 vps458278 systemd[1]: nginx.service: Start operation timed out. Terminating.
May 06 13:00:29 vps458278 systemd[1]: nginx.service: Control process exited, code=killed, status=15/TERM
May 06 13:00:29 vps458278 systemd[1]: nginx.service: Failed with result 'timeout'.
May 06 13:00:29 vps458278 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
如果我随后使用 手动启动它systemctl start nginx
,它会正常启动,没有任何问题。
这是我的 nginx 单元文件:
➜ ~ systemctl cat nginx
# /usr/lib/systemd/system/nginx.service
[Unit]
Description=A high performance web server and a reverse proxy server
After=network.target network-online.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
PrivateDevices=yes
SyslogLevel=err
ExecStart=/usr/bin/nginx -g 'pid /run/nginx.pid; error_log stderr;'
ExecReload=/usr/bin/nginx -s reload
KillMode=mixed
[Install]
WantedBy=multi-user.target
由于它仅在启动时失败,我虽然所需的单元之一(network.target、network-online.target、nss-lookup.target)出现错误,但我在日志中没有看到任何奇怪的东西。
为什么我的 nginx 没有在启动时启动?调试这种情况的最佳方法是什么?