解决mac os You don't have permission to access / on this server.

问题: mac下配置完apache和php环境后,访问localhost,出现403 Forbidden You don’t have permission to access / on this server提示。

网上解决方案:

方案1:


Apache的主配置文件在

/etc/apache2/httpd.conf

找到Directory目录,如果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的话,应该这么写


  Options Indexes MultiViews
  AllowOverride All
  # OSX 10.10 / Apache 2.4
  Require all granted

方案二


<Directory "/Users/yang/Sites/">
    Options Indexes MultiViews
    AllowOverride None
    Require all denied
Directory>

改成:

<Directory "/Users/yang/Sites/">
    Options Indexes MultiViews
    AllowOverride None
    Require all granted
Directory>

方案三:


<Directory "/Users/yang/Sites/">
    Options Indexes MultiViews
    AllowOverride None
    Require all granted
Directory>

改成


Options Indexes MultiViews
AllowOverride None
Require all granted
Allow from all

结果都不可行,后面发现其实是文件夹权限问题:

我的路径是:

/Users/shawn/Documents/Sites

其中Document权限是:
解决mac os You don't have permission to access / on this server._第1张图片
改成只读就OK了
解决mac os You don't have permission to access / on this server._第2张图片

你可能感兴趣的:(操作技巧)