Mac Lion 中禁止访问 Apache

Mac Lion 中禁止访问 Apache

我正在尝试配置 Apache 以与我的 Macbook Pro 中的 Symfony 配合使用。我已经安装了 Lion OSX。

  1. 我取消了该行的注释包括/private/etc/apache2/extra/httpd-vhosts.conf/etc/apache2/httpd.conf
  2. 我通过编辑/private/etc/apache2/extra/httpd-vhosts.conf. 并添加以下内容来配置 Apache:

::

NameVirtualHost *:80

<VirtualHost *.80>
  ServerName localhost
  DocumentRoot "/Library/WebServer/Documents"
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot "/Users/luiscberrocal/Documents/dev/lion_test/web"
  ServerName lion.localhost
<Directory "/Users/luiscberrocal/Documents/dev/lion_test/web">
   Options Indexes FollowSymlinks
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>
</VirtualHost>

3. 将以下内容添加到/私人/等/主机 127.0.0.1 狮子.本地主机

现在当我访问时,http://localhost/test.php我收到以下消息

Forbidden

You don't have permission to access /test.php on this server.

Apache/2.2.20 (Unix) DAV/2 PHP/5.3.6 带有 Suhosin-Patch 服务器,位于本地主机端口 80

我已经尝试过了:

chmod 777 test.php

chmod +x test.php 

如果我尝试访问http://lion.localhost/

我打开了,/var/log/apache2/error_log以下是我发现的相关内容:

[Sat Dec 31 09:37:49 2011] [notice] Apache/2.2.20 (Unix) DAV/2 PHP/5.3.6 with Suhosin-Patch configured -- resuming normal operations
[Sat Dec 31 09:37:53 2011] [error] [client ::1] (13)Permission denied: access to /test.php denied
[Sat Dec 31 09:37:55 2011] [error] [client ::1] (13)Permission denied: access to /test.php denied
[Sat Dec 31 09:38:13 2011] [notice] caught SIGTERM, shutting down
[Sat Dec 31 09:38:13 2011] [error] (EAI 8)nodename nor servname provided, or not known: Could not resolve host name *.80 -- ignoring! httpd: Could not reliably determine the server's fully qualified domain name, using Luis-Berrocals-MacBook-Pro.local for ServerName
[Sat Dec 31 09:38:14 2011] [warn] mod_bonjour: Cannot stat template index file '/System/Library/User Template/English.lproj/Sites/index.html'.
[Sat Dec 31 09:38:14 2011] [warn] mod_bonjour: Cannot stat template index file '/System/Library/User Template/English.lproj/Sites/index.html'.
[Sat Dec 31 09:38:14 2011] [notice] Digest: generating secret for digest authentication ...
[Sat Dec 31 09:38:14 2011] [notice] Digest: done
[Sat Dec 31 09:38:14 2011] [notice] Apache/2.2.20 (Unix) DAV/2 PHP/5.3.6 with Suhosin-Patch configured -- resuming normal operations
[Sat Dec 31 09:38:18 2011] [error] [client ::1] (13)Permission denied: access to /test.php denied
[Sat Dec 31 09:38:19 2011] [error] [client ::1] (13)Permission denied: access to /test.php denied
[Sat Dec 31 10:18:09 2011] [error] [client 127.0.0.1] (13)Permission denied: access to /test.php denied
[Sat Dec 31 10:18:15 2011] [error] [client 127.0.0.1] (13)Permission denied: access to / denied

我不知道我做错了什么。

答案1

<Directory "your/custom/directory">
  Options Indexes FollowSymLinks
  Order allow,deny
  Allow from all
</Directory>

在 /opt/local/apache2/conf/httpd.conf 的末尾

看看第 180 行到第 225 行,看看发生了什么。

答案2

看起来你的 Apache 配置文件写得不正确。

我会将目录中的内容移到 VirtualHost 上方,但您也无法访问您创建的第二个虚拟主机,因为您尝试使用错误的主机名访问它。您需要使用http://lion.localhost而不是本地主机。

为了简单起见,我还将删除第一个虚拟主机设置,然后将 lion.localhost 更改为 localhost。

希望有帮助,

缺口

<Directory "/Users/luiscberrocal/Documents/dev/lion_test/web">
   Options Indexes FollowSymlinks
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>

NameVirtualHost *:80

<VirtualHost *:80>
   DocumentRoot "/Users/luiscberrocal/Documents/dev/lion_test/web"
   ServerName lion.localhost
</VirtualHost>

答案3

只需/etc/apache2/httpd.conf评论以下几行

User _www
Group _www

并将用户设为您登录的用户。这样应该可行。

答案4

我也遇到了同样的问题。就我而言,目录没有适当的权限。

我将它们改为 755 并解决了问题。

相关内容