2016-10-26 15 views
0

構文的に正しいnginx設定が簡単です。私はシェフを使用してnginxをインストールし、シェフスクリプトは正常に動作します。nginxが起動に失敗する - トラブルシューティング

しかし、nginxのステータスを確認すると、失敗した状態になっています。私がnginxをリロードすると、それは再び失敗した状態になります。 -xn journalctlも除いて、エラーの多くを与えるdoesntの:

[[email protected] vagrant]# journalctl -xn 
-- Logs begin at Wed 2016-10-26 04:28:18 UTC, end at Wed 2016-10-26 04:45:00 UTC. -- 
Oct 26 04:45:00 localhost.localdomain kill[17003]: -s, --signal <sig>  send specified signal 
Oct 26 04:45:00 localhost.localdomain kill[17003]: -q, --queue <sig>  use sigqueue(2) rather than kill(2) 
Oct 26 04:45:00 localhost.localdomain kill[17003]: -p, --pid    print pids without signaling them 
Oct 26 04:45:00 localhost.localdomain kill[17003]: -l, --list [=<signal>] list signal names, or convert one to a name 
Oct 26 04:45:00 localhost.localdomain kill[17003]: -L, --table   list signal names and numbers 
Oct 26 04:45:00 localhost.localdomain kill[17003]: -h, --help  display this help and exit 
Oct 26 04:45:00 localhost.localdomain kill[17003]: -V, --version output version information and exit 
Oct 26 04:45:00 localhost.localdomain kill[17003]: For more details see kill(1). 
Oct 26 04:45:00 localhost.localdomain systemd[1]: nginx.service: control process exited, code=exited status=1 
Oct 26 04:45:00 localhost.localdomain systemd[1]: Unit nginx.service entered failed state. 
[[email protected] vagrant]# 

nginxのの-tが成功したと私は/var/log/nginx/errors.log

で何も見えない、他のはありますなぜこれが失敗するのかを正確にトラブルシューティングする方法?

両方systemctlステータスnginx.serviceができます:

[[email protected] vagrant]# systemctl status nginx.service 
nginx.service - The nginx HTTP and reverse proxy server 
    Loaded: loaded (/usr/lib/systemd/system/nginx.service; static) 
    Active: failed (Result: exit-code) since Wed 2016-10-26 04:45:00 UTC; 9h ago 
    Process: 17003 ExecStop=/bin/kill -s QUIT $MAINPID (code=exited, status=1/FAILURE) 
    Process: 16999 ExecStart=/opt/nginx-1.10.1/sbin/nginx (code=exited, status=0/SUCCESS) 
    Process: 16998 ExecStartPre=/opt/nginx-1.10.1/sbin/nginx -t (code=exited, status=0/SUCCESS) 
Main PID: 16999 (code=exited, status=0/SUCCESS) 

Oct 26 04:45:00 localhost.localdomain kill[17003]: -s, --signal <sig>  send specified signal 
Oct 26 04:45:00 localhost.localdomain kill[17003]: -q, --queue <sig>  use sigqueue(2) rather than kill(2) 
Oct 26 04:45:00 localhost.localdomain kill[17003]: -p, --pid    print pids without signaling them 
Oct 26 04:45:00 localhost.localdomain kill[17003]: -l, --list [=<signal>] list signal names, or convert one to a name 
Oct 26 04:45:00 localhost.localdomain kill[17003]: -L, --table   list signal names and numbers 
Oct 26 04:45:00 localhost.localdomain kill[17003]: -h, --help  display this help and exit 
Oct 26 04:45:00 localhost.localdomain kill[17003]: -V, --version output version information and exit 
Oct 26 04:45:00 localhost.localdomain kill[17003]: For more details see kill(1). 
Oct 26 04:45:00 localhost.localdomain systemd[1]: nginx.service: control process exited, code=exited status=1 
Oct 26 04:45:00 localhost.localdomain systemd[1]: Unit nginx.service entered failed state. 

systemctl猫nginx.serviceが与える:

[[email protected] sysadmin]# systemctl cat nginx.service 
Unknown operation 'cat'. 

IのCDをCD/libに/にsystemd /システムとnginx.serviceに猫を実行します。私はエコー$ MAINPIDを行う場合

[[email protected] system]# cat nginx.service 
[Unit] 
Description=The nginx HTTP and reverse proxy server 
After=network.target remote-fs.target nss-lookup.target 

[Service] 
ExecStartPre=/opt/nginx-1.10.1/sbin/nginx -t 
ExecStart=/opt/nginx-1.10.1/sbin/nginx 
ExecReload=/bin/kill -s HUP $MAINPID 
ExecStop=/bin/kill -s QUIT $MAINPID 
PrivateTmp=true 

[Install] 

は、私が何を取得します。

+2

あなたのnginx設定ではなく、あなたのnginx systemdユニットにエラーがあるように見えます。 'systemctl status nginx.service'と' systemctl cat nginx.service'を追加してください。 –

+0

@HardyRust - チェックの編集 – Scooby

+0

何かの理由で、 '$ MAINPID'は殺害の時にはepmtyです。もう一度確認してください。 'systemctl cat nginx.service'はユニット自体を表示します。 –

答えて

0

これはあまり良いunitfileではありません。タイプは設定されておらず、デフォルトはsimple、あなたはnginxの場合はforkingになります。これが間違った値の理由かもしれません$MAINPID値。 official unitを使用してみてください: - それは、管理者が作成した単位を対象とし、そのディレクトリを、優先度を持っている

[Unit] 
Description=The NGINX HTTP and reverse proxy server 
After=syslog.target network.target remote-fs.target nss-lookup.target 

[Service] 
Type=forking 
PIDFile=/run/nginx.pid 
ExecStartPre=/opt/nginx-1.10.1/sbin/nginx -t 
ExecStart=/opt/nginx-1.10.1/sbin/nginx 
ExecReload=/bin/kill -s HUP $MAINPID 
ExecStop=/bin/kill -s QUIT $MAINPID 
PrivateTmp=true 

[Install] 
WantedBy=multi-user.target 

あなただけ/etc/systemd/system/nginx.serviceに追加する必要があります。

関連する問題