我第一次在 Mac OS El Capitan 10.11.4 (15E65) 主机上设置站点,但是在访问 crmpicco.dev 时收到 HTTP 403 禁止错误。
Forbidden
You don't have permission to access / on this server.
/etc/apache2/extra/httpd-vhosts.conf:
<VirtualHost *:80>
DocumentRoot "/Users/crmpicco/Sites/crmpicco.co.uk/"
ServerName crmpicco.dev
</VirtualHost>
/etc/主机:
127.0.0.1 crmpicco.dev
这是我的目录列表:
PiccosMacBook:Sites crmpicco$ pwd
/Users/crmpicco/Sites
PiccosMacBook:Sites crmpicco$ ls -l
total 71488
drwxr-xr-x 12 crmpicco staff 408 18 May 19:06 crmpicco.co.uk
我尝试更改 Apache 运行的用户,但这并没有解决问题。
<IfModule unixd_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
#User _www
#Group _www
User crmpicco
Group staff
</IfModule>
我错过了一些明显的东西吗?我也尝试过这个建议(Apache localhost 403 error with Yosemite)
答案1
检查 Apache 错误日志。如果您发现消息显示“客户端被服务器配置拒绝”,那么您没有相应的<Directory>
块允许 Apache 提供来自/Users/crmpicco/Sites/crmpicco.co.uk/
.
如果错误日志提到(13) Permission denied
,则操作系统正在停止 Apache 从该目录提供文件(而不是 Apache 配置本身),您应该查看路径中所有目录的权限。请记住,Apache 需要能够遍历整个路径,而不仅仅是最后一个组件。
如果整个路径都正常,那么您可能正在运行某种形式的安全软件,阻止 Apache 提供文件服务。