Macports Apache2“無法綁定到位址”

Macports Apache2“無法綁定到位址”

我透過以下方式在 Mac OS X 10.7.4 上安裝了 apache2麥克波特斯

最近我無法存取我的 localhost 目錄,我收到 404,但我可以存取 127.0.0.1

我嘗試過重新啟動apache:

sudo /opt/local/apache2/bin/apachectl stop
sudo /opt/local/apache2/bin/apachectl start

我收到以下錯誤:

(48)Address already in use: make_sock: could not bind to address [::]:80
(48)Address already in use: make_sock: could not bind to address [::]:443

我檢查過網路共用已關閉。 apache 似乎已經在使用這些點或服務沒有正確停止。

我怎樣才能知道哪些連接埠正在使用?

答案1

“lsof”shell 指令可以準確地告訴您哪個程序正在使用系統中的哪些檔案和套接字位址。嘗試一下

sudo lsof

或者,因為輸出會很多,更好

sudo lsof | less

並在 http 連接埠上尋找某些內容。照常

man lsof

將為您提供有關如何自訂輸出的更多資訊。

答案2

作為參考,在 Mountain Lion 10.8.2 中,只需停止 apache2 服務即可解決問題:

sudo apachectl stop

這樣 httpd 進程就不會重新啟動,而且 Macports apache2 伺服器將在之後正常啟動。

答案3

在我的 Mojave (10.14.1) Mac 上,突然 Apache 無法再提供 IPv4 服務,然後給我錯誤 403 sudo killall httpd

sudo lsof | grep AMP | grep apache

甚至不起作用...只有 IPv6 可用...仍然是錯誤 403

對我有用的是:停用 macOS 的內建 Apache 伺服器。

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

在那之後:

sudo apachectl -k restart

要開心 :)

相關內容