简体   繁体   English

我的Apache本地主机无法正常工作-禁止

[英]My Apache localhost is not working - Forbidden

I am completely new to PHP and web servers. 我对PHP和Web服务器是完全陌生的。 I have a test PHP file. 我有一个测试PHP文件。 When I run this in the terminal I can see that PHP is working "php /Users/Fryza/Sites/phptest.php" 当我在终端中运行此程序时,我可以看到PHP正在运行“ php /Users/Fryza/Sites/phptest.php”

When I type these into the web browser I get 403 Forbidden error: 当我在网络浏览器中键入这些内容时,出现403禁止错误:

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

http://localhost/phptest.php

I have a file (/private/etc/apache2/users/fryza.conf) that has these contents: 我有一个包含以下内容的文件(/private/etc/apache2/users/fryza.conf):

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

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

I also have this directory /Library/Webserver/Documents - I used to have this as the document root but it wasn't working in this location either. 我也有这个目​​录/ Library / Webserver / Documents-我曾经以这个目录作为文档根目录,但是在这个位置也没有用。

I have read through a bunch of stack overflow posts but they are not working for me. 我已经阅读了一堆堆栈溢出帖子,但是它们对我不起作用。

The apache server definitely is running. apache服务器肯定正在运行。 PHP is working. PHP正在工作。 Just can't get the files to load in the browser. 只是无法将文件加载到浏览器中。

I'm running Mountain Lion 我在跑山狮

I did the same tutorial as the guy here and am having the same problem: 403 Forbidden error when accessing localhost on Mac OS X10.8 我和这里的人做的教程相同,并且遇到了相同的问题: 在Mac OS X10.8上访问localhost时出现403 Forbidden错误

This is the error log: 这是错误日志:

[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

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

If you are running skype, your localhost will not run because skype also use the port as localhost. 如果运行的是Skype,则本地主机将不会运行,因为Skype还将端口用作本地主机。 but when you run localhost first before skype it will work. 但是,当您在skype之前先运行localhost时,它将起作用。 but when skype run first, you must end task by pressing ctr+alt+del then task manager and select skype then end task .. 但是当首次运行Skype时,您必须先按ctr + alt + del然后选择 任务管理器 ,然后选择skype,然后选择 结束任务 ,即可结束任务

but that's only for info.. the real deal here is how your localhost work.. try to do this. 但这仅用于信息..真正的好处是您的本地主机如何工作..尝试执行此操作。

click the icon of your wamp server on the right bottom of your computer.. then click Restart All Services .. And run your localhost. 单击计算机右下角wamp服务器图标。然后单击重新启动所有服务 ..并运行本地主机。

That's all I know.. Im a newbie here.. tnx :) 这就是我所知道的..我是新手.. tnx :)

I finally figured it out. 我终于弄明白了。 I don't know WHY this worked - but it did. 我不知道为什么这样做有效-但确实如此。

I changed my fryza.conf file from: 我从以下位置更改了fryza.conf文件:

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

To: 至:

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

Can someone explain why this worked? 有人可以解释为什么这样做有效吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM