在mac下配置完apache和php環境后,通過localhost訪問頁面,出現403Forbidden。頁面提示:
Forbidden
You don't have permission to access / on this server.
解決辦法是修改/etc/apache/httpd.conf的配置
1、打開終端
2、cd /etc/apache2 --切換到apache目錄
3、sudo vim httpd.conf --需要輸入電腦密碼
如果apache版本是2.2的話,應該這么寫
<Directory "/Users/apple/Sites/">--/Users/apple/Sites是自己設置的apache指向的站點目錄,默認是/Library/WebServer/DocumentOptions Indexes MultiViews
AllowOverride All
# OSX 10.9 / Apache 2.2
Order from deny, allow
</Directory>
如果apache版本是2.4的話,應該這么寫
<Directory "/Users/apple/Sites/">--/Users/apple/Sites是自己設置的apache指向的站點目錄,默認是/Library/WebServer/DocumentOptions Indexes MultiViewsAllowOverride All# OSX 10.10 / Apache 2.4
Require all granted
</Directory>
參考博文鏈接:https://www.jianshu.com/p/7dd74c57d56c
