CentOS 7 で HTTPD を再起動できない

CentOS 7 で HTTPD を再起動できない

CentOS 7 を実行しているインスタンスがあります。再起動すると問題が発生しますhttpd

私の設定は正常に動作しており、サイトは希望どおりにブロードキャストされています。さらに、コマンド を実行するとsudo apachectl configtest、 が返されますSyntax OK

しかし、再起動するとhttpd、次のステータス メッセージが表示され、準拠できません。

● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2018-08-28 12:30:26 CEST; 6s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 9569 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 9568 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 9568 (code=exited, status=1/FAILURE)

Aug 28 12:30:26 vps httpd[9568]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
Aug 28 12:30:26 vps httpd[9568]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
Aug 28 12:30:26 vps httpd[9568]: no listening sockets available, shutting down
Aug 28 12:30:26 vps httpd[9568]: AH00015: Unable to open logs
Aug 28 12:30:26 vps systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Aug 28 12:30:26 vps kill[9569]: kill: cannot find process ""
Aug 28 12:30:26 vps systemd[1]: httpd.service: control process exited, code=exited status=1
Aug 28 12:30:26 vps systemd[1]: Failed to start The Apache HTTP Server.
Aug 28 12:30:26 vps systemd[1]: Unit httpd.service entered failed state.
Aug 28 12:30:26 vps systemd[1]: httpd.service failed.

httpd再起動すると、 の代わりに何か他のものが動作していることがわかります。そのため、 を実行しますnetstat -tulpn | grep :80

tcp        0      0 0.0.0.0:8060            0.0.0.0:*               LISTEN      2560/nginx: master  
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      2560/nginx: master  
tcp        0      0 127.0.0.1:8080          0.0.0.0:*               LISTEN      1434/unicorn master 
tcp        0      0 127.0.0.1:8082          0.0.0.0:*               LISTEN      1307/sidekiq 5.1.3 

Nginx上記の結果は、私のシステムにインストールされておらず、which nginx何も返されないため、少し混乱します。

ただし、インスタンスを再起動すると、httpd意図したとおりに動作します。

問題を解決するにはどうすればいいですか?

答え1

はい、謎は解けました。Gerald Schneider に感謝します。(幸いなことにトロイの木馬ではありませんでしたが)

実行することでps -Af | grep $pid、さらに詳しい情報が得られ、GitLab に注目するようになりました。(何か怪しい点があることはわかっていましたが、問題の根本原因を突き止めて適切に特定することはできませんでした)

httpdは と競合していましたgitlab。 を実行してからsudo gitlab-ctl stop再起動してみるとhttpd、すべて通常通りになりました。

また、この質問Apache - GitLab - Nginx のジレンマについてさらに詳しく述べています。(最初に言及されているのは、Apache と GitLab がポート 80 で矛盾していることです :])

答え2

systemctlコマンドを使用して実行中のサービスを識別できます。

あなたの場合systemctl list-unit-files | grep nginx

systemctl list-unit-files | grep nginx
nginx-nr-agent.service                 generated
nginx.service                          enabled  

その後、次のコマンドで実行中のサービスに関する詳細情報を確認できます。systemctl status servicename

● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2018-08-28 15:03:08 EEST; 47min ago
     Docs: man:nginx(8)
  Process: 1455 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
  Process: 1460 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
  Process: 1458 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 Main PID: 1462 (nginx)
    Tasks: 2 (limit: 4915)
   CGroup: /system.slice/nginx.service
           ├─1462 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
           └─1463 nginx: worker process

おそらく、ExecStop と ExecStart はバイナリが配置されている場所を識別するのに役立ちます。

答え3

マスターはLinuxサーバのpostfixによって使用されます。次のコマンドでpostfixを停止してみてください。

/sbin/service postfix stop

また、設定にpostfixが必要ない場合は、次のコマンドでサーバーの再起動時にpostfixの再起動を停止できます。

chkconfig postfix off

また、エラーから、0.0.0.0:80 で httpd を起動しようとしていることは明らかです。より具体的なエラーを取得するには、代わりに httpd.conf ファイルで IP アドレスを使用してみてください。

ここで、httpd サービスを停止して再起動してみてください。

関連情報