我的 simplesaml 运行良好,直到我在 Ubuntu 上将 Apache 升级到 2.4.6
我得到的错误:
Forbidden
You don't have permission to access /simplesaml/ on this server.
我的 simplesaml 运行良好,直到我在 Ubuntu 上将 Apache 升级到 2.4.6
我得到的错误:
Forbidden
You don't have permission to access /simplesaml/ on this server.
在 Apache 上安装 simplesamlphp 的说明只需要 simplesamlphp 目录的别名:
https://simplesamlphp.org/docs/stable/simplesamlphp-install#section_6
但是对于 Apache 2.4.6+,安全性发生了变化——当我添加一个 Directory 指令时它对我有用。例如:
<VirtualHost *:80>
ServerName mywebsite.dev
DocumentRoot /home/myuser/www/mywebsite/
<Directory /home/myuser/www/mywebsite/>
Require all granted
</Directory>
Alias /simplesaml /var/simplesamlphp/www
<Directory /var/simplesamlphp/www/>
Require all granted
</Directory>
</VirtualHost>
虽然选择的答案是正确的,但我想补充一点,SELinux 也可能导致此错误。在网上看了很多例子之后,我花了几个小时才意识到这是我的问题。
如果您正在运行 SELinux,请确保您运行以下命令:
chcon -R --reference=/var/www /var/simplesamlphp
这会将/var/simplesamlphp
目录置于与/var/www
. 您不能只将/var/simplesamlphp/www
目录放在相同的上下文中,因为 _include.php 访问/var/simplesamlphp/lib
.
我希望这可以防止有人像我一样在这个问题上花费太多时间。
如果您通过 compose 安装了 simplesamlphp,这可能会更复杂。除了@RusselEngland 回答需要添加正确的 Apache 配置之外,如果您仍然收到 403,您需要确保该文件没有被 .htaccess 中的规则阻止。
阿帕奇配置:
<VirtualHost *:80>
DocumentRoot /var/www/html
Alias /simplesaml /var/www/html/vendor/simplesamlphp/simplesamlphp/www
<Directory /var/www/html/vendor/simplesamlphp/simplesamlphp/www/>
Require all granted
</Directory>
</VirtualHost>
.htaccess(在 /var/www/html 中);
<IfModule mod_rewrite.c>
#...
RewriteCond %{REQUEST_URI} !/core/[^/]*\.php$
RewriteCond %{REQUEST_URI} !/core/modules/system/tests/https?.php
RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics.php$
RewriteCond %{REQUEST_URI} !^/simplesaml/* # Add this condition
RewriteRule "^(.+/.*|autoload)\.php($|/)" - [F]
</IfModule>