【问题标题】:Windows server 2012 : Access forbidden for xampp projectWindows server 2012:xampp 项目禁止访问
【发布时间】:2018-11-24 05:45:46
【问题描述】:

使用安装了 XAMPP 的 windows server 2012(Apache/2.4.33 (Win32) OpenSSL/1.0.2o PHP/5.6.36)检查了几乎 stackoverflow 的答案,但得到了同样的错误。

xampp 不会从 htdocs 访问除 xampp 仪表板以外的任何项目。

错误:

httpd-vhost.conf:

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/mysite"
    ServerName local.yourdomain.com
    <Directory "C:/xampp/htdocs/mysite">
        Require all granted 
    </Directory>
</VirtualHost>

主机:

127.0.0.1       localhost
127.0.0.1       local.yourdomain.com

httpd.conf:

DocumentRoot "C:/xampp/htdocs/mysite"
<Directory "C:/xampp/htdocs/mysite">
    #
    # 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 Includes ExecCGI

    #
    # 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 All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted

</Directory>

【问题讨论】:

  • 我的网站文件夹是空的?
  • 您是否检查过您的目录权限以确保 apache(至少)具有对 htdocs 目录的读取权限?如果 Apache 作为服务安装(即它将以 windows 启动),那么它将以系统用户身份运行。
  • @Metalik - 未选中,但默认进入 xampp 仪表板。它仅在 htdocs 中,所以 htdocs 可以访问吗?
  • 请告诉我如何检查 htdocs 的 apache 读取访问权限。
  • 尝试更改虚拟主机上的文档根目录valuebound.com/resources/blog/…

标签: php xampp windows-server-2012


【解决方案1】:

我发现这些 403 错误(几乎)总是 Apache 配置错误。不幸的是,日志中没有很多诊断。

在你的 httpd-vhosts.conf 文件中试试这个:

    <VirtualHost *:80>
      ServerName example.local
      DocumentRoot "C:\Users\shipl\htdocs\example"
      <Directory "C:\Users\shipl\htdocs\example">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
      </Directory>
    </VirtualHost>

您的主机将拥有:

127.0.0.1       localhost
127.0.0.1       example.local

请注意,'example.local' 和 '\htdocs\example' 在所有引用中必须保持一致。

希望这会有所帮助。

【讨论】:

  • 现在有一些改进,只有特定目录给出了相同的错误,在 htdocs 中创建了新文件夹并测试 phpinfo() 运行良好。
  • 我的旧运行目录会出现什么问题?它也有 index.php。
  • 我正在尝试使用 IP 地址,但项目文件夹名称不同。但我的第一条评论运行良好。
  • 在将 .htcdess 添加到根目录时遇到问题。 RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
  • 很高兴它在新文件夹中工作。旧文件夹的问题必须是其他问题(给定相同的 Apache 配置。请注意,这是 HTTP 的配置,而不是 HTTPS,这是另一个需要不同/额外配置的问题。您可能想提出一个描述该问题的新问题。
猜你喜欢
  • 2017-09-21
  • 2015-06-26
  • 2018-10-07
  • 2020-07-10
  • 2013-07-22
  • 2015-11-11
  • 2013-01-19
  • 2014-10-22
  • 2017-02-20
相关资源
最近更新 更多