0

我对 PHP 和 Web 服务器完全陌生。我有一个测试 PHP 文件。当我在终端中运行它时,我可以看到 PHP 正在运行“php /Users/Fryza/Sites/phptest.php”

当我在网络浏览器中输入这些内容时,我收到 403 Forbidden 错误:

http://localhost/~fryza/phptest.php

http://localhost/phptest.php

我有一个包含以下内容的文件(/private/etc/apache2/users/fryza.conf):

<Directory "/Users/fryza/Sites/">
Options FollowSymLinks Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>

我在 private/etc/apache2/httpd.conf 中的 DocumentRoot 是 /Users/Fryza/Sites/

我也有这个目​​录 /Library/Webserver/Documents - 我曾经把它作为文档根目录,但它也不能在这个位置工作。

我已经阅读了一堆堆栈溢出帖子,但它们对我不起作用。

apache 服务器肯定正在运行。PHP 正在工作。只是无法让文件加载到浏览器中。

我在跑山狮

我和这里的人做了同样的教程并且遇到了同样的问题: 在 Mac OS X10.8 上访问 localhost 时出现 403 Forbidden error

这是错误日志:

[Mon Oct 28 17:57:17 2013] [notice] caught SIGTERM, shutting down
[Mon Oct 28 17:57:17 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Mon Oct 28 17:57:17 2013] [warn] module php5_module is already loaded, skipping
[Mon Oct 28 17:57:17 2013] [notice] Digest: generating secret for digest authentication ...
[Mon Oct 28 17:57:17 2013] [notice] Digest: done
[Mon Oct 28 17:57:17 2013] [notice] Apache/2.2.24 (Unix) DAV/2 PHP/5.3.26 mod_ssl/2.2.24   OpenSSL/0.9.8y configured -- resuming normal operations

访问日志: ::1 - - [28/Oct/2013:18:05:38 -0700] "GET /~fryza/phptest.php HTTP/1.1" 403 220

4

2 回答 2

0

如果您正在运行 Skype,您的 localhost 将不会运行,因为 Skype 还使用该端口作为 localhost。但是,当您在 Skype 之前先运行 localhost 时,它会起作用。但是当Skype首先运行时,您必须通过按ctr + alt + del然后按任务管理器选择Skype然后结束任务来结束任务..

但这仅用于信息..这里真正的交易是您的本地主机如何工作..尝试这样做。

单击计算机右下角的wamp 服务器图标。然后单击重新启动所有服务。然后运行本地主机。

这就是我所知道的..我是这里的新手.. tnx :)

于 2014-05-12T09:30:12.433 回答
-1

我终于弄明白了。我不知道为什么会这样 - 但确实如此。

我从以下位置更改了我的 fringza.conf 文件:

<Directory />
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Allow from all
</Directory>

至:

<Directory />
    #Options FollowSymLinks
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order deny,allow
    Allow from all
</Directory>

有人可以解释为什么这有效吗?

于 2013-10-29T02:35:54.703 回答