【发布时间】:2015-06-09 04:56:22
【问题描述】:
My PHP code is not executed when I access the root directory with
http://localhost/sample.php
我要运行的代码是:
<?php phpinfo(); ?>
但我的代码只是显示在浏览器上,并没有执行。
我尝试过:
- 多次重启所有服务,包括将 WampServer 上线;
- 将
httpd.conf中的监听端口改为8080。
PHP 错误日志中没有任何错误,但 Apache 错误日志中出现以下错误:
[Tue Jun 09 08:53:52 2015] [notice] Apache/2.2.21 (Win32) PHP/5.3.10 configured -- resuming normal operations
[Tue Jun 09 08:56:30 2015] [error] [client ::1] client denied by server configuration: C:/wamp/www/
[Tue Jun 09 08:56:30 2015] [error] [client ::1] client denied by server configuration: C:/wamp/www/favicon.ico, referer: http://localhost/
[Tue Jun 09 09:22:23 2015] [error] [client ::1] (20023)The given path was above the root path: Cannot map GET /C:/wamp/www HTTP/1.1 to file
[Tue Jun 09 09:22:24 2015] [error] [client ::1] client denied by server configuration: C:/wamp/www/favicon.ico, referer: http://localhost/C:/wamp/www
[Tue Jun 09 09:26:26 2015] [error] [client ::1] client denied by server configuration: C:/wamp/www/
[Tue Jun 09 09:26:26 2015] [error] [client ::1] client denied by server configuration: C:/wamp/www/favicon.ico, referer: http://localhost/
[Tue Jun 09 09:26:46 2015] [error] [client ::1] client denied by server configuration: C:/wamp/apps/phpmyadmin3.4.10.1/
[Tue Jun 09 09:26:46 2015] [error] [client ::1] client denied by server configuration: C:/wamp/www/favicon.ico, referer: http://localhost/phpmyadmin/
[Tue Jun 09 09:30:10 2015] [error] [client ::1] client denied by server configuration: C:/wamp/apps/phpmyadmin3.4.10.1/
[Tue Jun 09 09:30:10 2015] [error] [client ::1] client denied by server configuration: C:/wamp/www/favicon.ico, referer: http://localhost/phpmyadmin/
[Tue Jun 09 09:31:21 2015] [error] [client ::1] client denied by server configuration: C:/wamp/apps/phpmyadmin3.4.10.1/
[Tue Jun 09 09:31:21 2015] [error] [client ::1] client denied by server configuration: C:/wamp/www/favicon.ico, referer: http://localhost/phpmyadmin/
【问题讨论】:
-
您检查过 apache 目录中的 access.log 文件吗?它可能会显示一些错误消息。如果有,请与我们分享,我们可以提供帮助。
-
不,我以前没有检查过,但现在我打开它,我提出了很多 Get 请求,其中一些是
::1 - - [09/Jun/2015:08:56:30 +0530] "GET / HTTP/1.1" 403 202 ::1 - - [09/Jun/2015:08:56:30 +0530] "GET /favicon.ico HTTP/1.1" 403 213 ::1 - - [09/Jun/2015:09:22:23 +0530] "GET /C:/wamp/www HTTP/1.1" 403 213 -
您确定您使用的是正确版本的 wampserver 吗?我的意思是 x86 和 x64。更重要的是:您的项目目录在哪里?更改其位置,如 C:\project 并重试。
-
我第一次尝试使用 PHP .. 我尝试执行的 php 文件位于 c:\wamp\www 中。我不确定 wamp 服务器的版本
-
检查 error_log 文件。有什么不寻常的地方,比如那里的任何错误?如果有,请更新您的帖子并与我们分享。