gpt4 book ai didi

PHP 仅在 Apache 中不呈现单个别名

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:19:11 26 4
gpt4 key购买 nike

我在 httpd.conf 文件的末尾设置了以下别名,但得到了一些意想不到的结果

Alias /simplesaml /var/simplesamlphp/www
<Directory /var/simplesamlphp/www/>
Require all granted
AddType application/x-httpd-php .php
AddHandler application/x-httpd-php .php
</Directory>

当导航到 URL/simplesaml 时,页面加载为白屏,当查看源代码时,页面包含 PHP 代码。这不会发生在服务器上正确呈现 PHP 文件的任何其他站点上。

我可以看到服务器正在获取别名,因为删除了

Require all granted

行,导致 403 禁止错误。删除 AddType/AddHandler 行会导致浏览器下载 PHP 文件。


更新:11/09/17

我通过向我们的托管公司提出支持票得到了以下回应

I did a quick test on one of our test servers and copied over the same configuration file, just setting up a simple index.php inside of /var/simplesamlphp/www and was able to replicate the issue by creating the alias. I suspect that this is related to the change in PHP handlers from CentOS 5/6 to 7 and may require a syntax update in the configuration file. I don't know confidently off hand but I'll dig into this a bit more for you to provide you with more information and hopefully we'll get you on the right track!

几个小时后我收到了这个回复

We were able to resolve the issue of "somethingbig.co.uk/simplesaml" being downloaded when you visit the URL in a browser. We resolved the issue by adjusting your httpd.conf file. The lines below were added and Apache was restarted.

<Files ~ (\.php$)>
SetHandler proxy:unix:/var/www/vhosts/system/somethingbig.co.uk/php-fpm.sock|fcgi://127.0.0.1:9000
</Files>

但是,这实际上根本没有解决任何问题,我现在收到“未指定输入文件”。错误,当我将“index.php”添加到 URL 末尾时,文件仍在下载。


更新 2:11/09/17

以上确实解决了问题,错误日志显示顶级域不允许访问该 base_dir,更新后一切正常。

最佳答案

在 Centos 7 中,需要将以下代码添加到您的 httpd.conf 文件中以允许别名正常运行

<Files ~ (\.php$)>
SetHandler proxy:unix:/var/www/vhosts/system/[domain]/php-fpm.sock|fcgi://127.0.0.1:9000
</Files>

将 [domain] 替换为您自己的别名域。

关于PHP 仅在 Apache 中不呈现单个别名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46157237/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com