Mac 配置 Apache

作者: 开车去环游世界 | 来源:发表于2016-11-19 01:01 被阅读25次
<VirtualHost *:80>
    DocumentRoot "/Users/xb/www/study"
    ServerName frontendx.study
    <Directory "/Users/xb/www/study">
        # AllowOverride All        # Deprecated
        # Order Allow,Deny       # Deprecated
        # Allow from all           # Deprecated
        # --New way of doing it
        Require all granted 
    </Directory>
</VirtualHost>

在mac下配置完apache和PHP环境后,通过localhost访问页面,出现403Forbidden。页面提示

Forbidden
You don’t have permission to access / on this server. 

1:解决办法是修改/etc/apache/httpd.conf的配置
2:如果你只要配置虚拟主机,可以在虚拟主机里面写这个配置
如果apache版本是2.2的话,应该这么写

<Directory "/Users/apple/Sites/">
  Options Indexes MultiViews
  AllowOverride All
  # OSX 10.9 / Apache 2.2
  Order from deny, allow
</Directory>

如果apache版本是2.4的话,应该这么写

<Directory "/Users/apple/Sites/">
  Options Indexes MultiViews
  AllowOverride All
  # OSX 10.10 / Apache 2.4
  Require all granted
</Directory>

相关文章

网友评论

    本文标题:Mac 配置 Apache

    本文链接:https://www.haomeiwen.com/subject/dxispttx.html