dougu1952 2015-06-09 04:56
浏览 69
已采纳

PHP文件没有执行代码

My PHP code is not executed when I access the root directory with

http://localhost/sample.php

The code I want to run is:

<?php phpinfo(); ?>

But my code is just shown on the browser, it is not executing.

I tried to:

  • restart all services several times including putting WampServer online;
  • changing the listening port in httpd.conf to 8080.

There is not any error in the PHP error log But in Apache Error Log there are errors as following:

[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/
  • 写回答

3条回答 默认 最新

  • drdr123456 2015-06-09 11:27
    关注

    Your problem is that your browser has decided to use the IPV6 stack rather than the IPV4 stack hence the ip address ::1 in the error messages rather that the more usual `127.0.0.1' IPV4 loopback address.

    As IPV6 was very new when the version of WAMPServer that comes with Apache/2.2.21 Apache was released, and is not configured to expect access from the IPV6 loopback address ::1 so you will have to amend the config.

    Edit httpd.conf using the wampmanager menus to make sure you edit the correct file. Then look for this section, it will probably look something like this :-

    <Directory "c:/wamp/www/">
        #
        # Possible values for the Options directive are "None", "All",
        # or any combination of:
        #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
        #
        # Note that "MultiViews" must be named *explicitly* --- "Options All"
        # doesn't give it to you.
        #
        # The Options directive is both complicated and important.  Please see
        # http://httpd.apache.org/docs/2.2/mod/core.html#options
        # for more information.
        #
        Options Indexes FollowSymLinks
    
        #
        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be "All", "None", or any combination of the keywords:
        #   Options FileInfo AuthConfig Limit
        #
        AllowOverride all
    
        #
        # Controls who can get stuff from this server.
        #
    
    #   onlineoffline tag - don't remove
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1 
    
    </Directory>
    

    So change these lines as follows

    #   onlineoffline tag - don't remove
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1 ::1 localhost     <-- this line
    

    See I have added the ip address ::1 and also localhost

    You will also have to change the file that controls access to phpMyAdmin in the same way :-

    Edit \wamp\alias\phpmyadmin.conf and change

    Order Deny,Allow
    Deny from all
    Allow from localhost 127.0.0.1
    

    To

    Order Deny,Allow
    Deny from all
    Allow from localhost 127.0.0.1 ::1
    

    You may also need to amend the sqlbuddy and webgrind configs in the same way if you actually use those features.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据