無法在 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 困境。

答案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

master 在 Linux 伺服器中由 postfix 使用。嘗試透過以下命令停止 postfix

/sbin/service postfix stop

另外,如果您的設定不需要 postfix,您可以透過以下命令阻止它在伺服器重新啟動時重新啟動

chkconfig postfix off

另外,從錯誤中可以清楚地看出您正在嘗試在 0.0.0.0:80 上啟動 httpd。嘗試使用 httpd.conf 檔案中的 IP 位址來取得更具體的錯誤。

現在嘗試停止並重新啟動 httpd 服務。

相關內容