在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/Document
Options 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/Document
Options Indexes MultiViews
AllowOverride All
# OSX 10.10 / Apache 2.4
Require all granted
</Directory>
参考博文链接:https://www.jianshu.com/p/7dd74c57d56c