为PHP配置httpd.conf(您没有权限访问此服务器上的/ PHP / PHP -cgi.exe/index.php


configure httpd.conf for PHP ( You don't have permission to access /php/php-cgi.exe/index.php on this server. )

我已经在WINDOWS上成功安装了Apache,并且可以毫无问题地打开HTML文件。我还在服务器上安装了PHP。我配置Apache和PHP按照以下教程:http://www.sitepoint.com/how-to-install-apache-on-windows/http://www.sitepoint.com/how-to-install-php-on-windows/

如前所述,apache允许我在我的网站打开html文件。当添加一个php文件,我得到错误:You don't have permission to access /php/php-cgi.exe/index.php on this server.

PHP安装到c:'PHP,并在c:'apache24

我尝试了几个选项来修复http .conf文件,但没有任何成功。

我的配置文件片段如下:

<Directory "c:/WebPages">
   #
    # 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.4/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:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    ##AllowOverride None
    #
    # Controls who can get stuff from this server.
    #
    ##Require all granted
    #Options FollowSymLinks
   AllowOverride None
Options None
Require all granted
Allow from all

</Directory>

这允许我查看html文件,但不是php,所以我认为我需要允许权限到c:' php文件夹,但不知道什么?

欢迎任何建议。一如既往的感谢。

这是因为您的CGI文件夹不在PHP安装文件夹中。尝试将这些代码行添加到httpd.conf文件中:

<Directory "c:/php">
    AllowOverride None
    Options None
    Require all granted
</Directory>

如果你没有安装PHP在c:' PHP,改变到你安装它的地方。记住,使用前斜杠而不是后斜杠(我总是搞混;