【问题标题】:Repoint global DocumentRoot, still run PHP重新指向全局 DocumentRoot,仍然运行 PHP
【发布时间】:2013-12-29 18:13:16
【问题描述】:

我有一个服务器正在为一个项目提供一个网页。

项目存储在服务器上的用户目录中。 (/home/user/theproject/webstuff)。

最初,我使用userdir 模块通过http://theserver/user 和从/home/user/public_html/home/user/theproject/webstuff 的符号链接来访问它以指示文件的位置。

但是,最终,最好从http://theserver 提供文件,而不必指明用户(因为实际上只有一个用户)。

然后我有了一个绝妙的主意。

相反,我会重写我的 /etc/apache2/sites-enabled/000-default.conf 文件以读取:

<VirtualHost *:80>
  ServerAdmin webmaster@localhost
  DocumentRoot /home/user/theproject/webstuff

  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

现在一切都很好……除了 PHP 不再运行。

相反,会引发以下错误:

AH01630: client denied by server configuration: /home/user/theproject/webstuff/script.php

对于客户端,这显示为 403 Forbidden 错误。

所以这是一个双重问题:

  1. 有没有更好的方法来实现我的目标?
  2. 在这种情况下如何启用 PHP?

【问题讨论】:

  • 检查了提议的重复项@MartyMcVry 的所有解决方案,但似乎没有一个有效。由于建议的重复项的失败模式是将 PHP 下载给用户,而我的失败模式是 403 禁止,因此这些问题很有可能涵盖不同的领域,因此不是重复项。
  • 您的文档根目录似乎存在允许/拒绝问题。尝试在 VirtualHost 中添加一个目录块。

标签: php apache


【解决方案1】:

您可以在此处找到对此错误的详细描述以及几种可能的解决方案: http://wiki.apache.org/httpd/ClientDeniedByServerConfiguration

【讨论】:

    【解决方案2】:

    事实证明,我不得不编辑/etc/apache2/apache2.conf

    在第 164 行有一个块,我必须修改如下:

    #<Directory /var/www>
    <Directory /home/user/theproject/webstuff>
      Options Indexes FollowSymLinks
      AllowOverride None
      Require all granted
    </Directory>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-12-01
      • 2018-05-06
      • 1970-01-01
      • 2017-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多