2017-07-26 64 views
1

我想在運行Sierra的Mac上使用Apache和PHP設置本地Web服務器。我跟着這個教程:無法更改apache的文檔根目錄2.4

https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions

而且我停留在從httpd.config更改文檔根目錄,無論出於何種原因這種變化不生效的。如果我輸入http://localhost它仍然會顯示「It works」,它仍會使用原始html文件。

另一個奇怪的是,顯然我無法阻止apache。我試圖運行

$ sudo apachectl stop 

,但我仍然無法訪問http://localhost

,如果我跑

$ brew services list 

httpd24停止。是什麼賦予了?我究竟做錯了什麼?

回答

2

有一個預先安裝了macOS的apache實例。所以你現在已經安裝了兩個版本的Apache。如果檢查:

which apachectl 

,你可能會獲得:

/usr/sbin/apachectl 

這是apachectl正式的MacOS版本。與停止:

sudo apachectl stop 

禁用與預安裝的Apache的自動加載(如在the tutorial you mentioned解釋):

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null 

要運行自制軟件的版本做:

brew services run httpd24 

停止它:

brew services stop httpd24 

將其註冊爲在登錄時啓動:

brew services start httpd24