1. ホーム
  2. nginx

nginx スタートアップ・エラー。nginx.serviceのジョブは、制御プロセスがエラーコードで終了したため失敗しました。

2022-02-14 08:57:48

nginx 起動エラー。 制御プロセスがエラーコードで終了したため、nginx.service のジョブに失敗しました。

>>> service nginx restart
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

>>> 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 V 2018-08-31 11:08:14 CST; 5min ago
  Process: 4668 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=1/FAILURE)
  Process: 28149 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
  Process: 28146 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 Main PID: 4455 (code=killed, signal=KILL)

Aug 31 11:08:13 user-70DGA014CN nginx[28149]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Aug 31 11:08:13 user-70DGA014CN nginx[28149]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Aug 31 11:08:13 user-70DGA014CN nginx[28149]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Aug 31 11:08:13 user-70DGA014CN nginx[28149]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Aug 31 11:08:14 user-70DGA014CN nginx[28149]: nginx: [emerg] still could not bind()
Aug 31 11:08:14 user-70DGA014CN systemd[1]: nginx.service: Control process exited, code=exited status=1
Aug 31 11:08:14 user-70DGA014CN systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Aug 31 11:08:14 user-70DGA014CN systemd[1]: nginx.service: Unit entered failed state.
Aug 31 11:08:14 user-70DGA014CN systemd[1]: nginx.service: Failed with result 'exit-code'.
Aug 31 11:08:49 user-70DGA014CN systemd[1]: Stopped A high performance web server and a reverse proxy server.

journalctl -xe

>>> journalctl -xe
Aug 31 11:08:12 user-70DGA014CN nginx[28149]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Aug 31 11:08:12 user-70DGA014CN nginx[28149]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Aug 31 11:08:12 user-70DGA014CN nginx[28149]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Aug 31 11:08:12 user-70DGA014CN nginx[28149]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Aug 31 11:08:13 user-70DGA014CN nginx[28149]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Aug 31 11:08:13 user-70DGA014CN nginx[28149]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Aug 31 11:08:13 user-70DGA014CN nginx[28149]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Aug 31 11:08:13 user-70DGA014CN nginx[28149]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Aug 31 11:08:14 user-70DGA014CN nginx[28149]: nginx: [emerg] still could not bind()
Aug 31 11:08:14 user-70DGA014CN systemd[1]: nginx.service: Control process exited, code=exited status=1
Aug 31 11:08:14 user-70DGA014CN systemd[1]: Failed to start A high performance web server and a reverse proxy server.
-- Subject: nginx.service unit has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- nginx.service unit has failed.
-- 
-- The result is "failed".
Aug 31 11:08:14 user-70DGA014CN systemd[1]: nginx.service: Unit entered failed state.
Aug 31 11:08:14 user-70DGA014CN systemd[1]: nginx.service: Failed with result 'exit-code'.
Aug 31 11:08:49 user-70DGA014CN systemd[1]: Stopped A high performance web server and a reverse proxy server.
-- Subject: nginx.service unit has finished stopping operation
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- nginx.service unit has ended its operation.

上記のメッセージから、nginx のポート 80 が使用されていることがわかります(ただし、これは主な問題ではありません)。

最初の回避策

注意

    etc/nginx/conf.d/default.conf や /etc/nginx/nginx.conf ファイルを変更して、systemctl restart nginx.service というコマンドを使うことがあると、以下のようなエラーメッセージが表示されることがあります。

>>> service nginx restart
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.

この時点で default.conf または nginx.conf ファイルを開いて、セミコロンが抜けていないかどうか確認する必要があります。

2つ目の回避策

  1.  nginxのアンインストール をクリックし、nginx関連のファイルを削除します。

  2. nginxの再インストール