为什么我的 PHP 源代码会显示?
因此,我将以下内容添加到我的 http.conf 文件中:
Listen443
NameVirtualHost *:443
<VirtualHost *:443>
DocumentRoot /PATH_TO/www
ServerName www.domain.com
SSLEngine on
SSLCertificateFile /PATH_TO/domain.crt
SSLCertificateKeyFile /PATH_TO/domain.key
SSLCertificateChainFile /PATH_TO/intermediate.crt
</VirtualHost>
https://www.domain.com 现在可以工作,但它显示 PHP源代码?这可能是什么原因?
So, I added the following to my http.conf file:
Listen443
NameVirtualHost *:443
<VirtualHost *:443>
DocumentRoot /PATH_TO/www
ServerName www.domain.com
SSLEngine on
SSLCertificateFile /PATH_TO/domain.crt
SSLCertificateKeyFile /PATH_TO/domain.key
SSLCertificateChainFile /PATH_TO/intermediate.crt
</VirtualHost>
https://www.domain.com works now, but it displays the PHP source code? What could be the reason for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
原因是“服务器配置错误”;-)
它选择将 PHP 文件作为“纯内容”提供服务,而不是将它们交给 PHP 引擎进行处理。这与 SSL 没有任何关系(它会很乐意通过安全连接发送“纯内容”)。
来自PHP:安装:
以及来自< a href="http://forums.devarticles.com/web-server-configuration-51/php-pages-won-t-load-show-source-code-apache-2t-52648.html" rel="nofollow noreferrer">PHP 页面无法加载:
看到某种模式了吗? :-) 无论如何,请阅读特定平台/服务器的详细安装说明。
快乐编码。
"Server configuration error" is the reason ;-)
It is choosing to serve PHP files as "plain content" instead of handing them to a PHP engine for processing. This doesn't have anything to do with SSL (it will just as happily send the "plain content" over a secure connection).
From PHP: Installation:
And from PHP pages won't load:
See a pattern? :-) In any case, read the fine installation instructions for the particular platform/server.
Happy coding.
也可能是您的 php.ini 配置设置为不解析短 php 标签之间的代码。
It could also be that your php.ini configuration is set to not parse code between short php tags.
在 centos 中,由于缺少 php 模块,可能会发生这种情况,要解决该问题,我们必须安装
In centos this can happen because of php-module missing, to fix that issue we have to install
只需在浏览器中输入 LOCALHOST 即可。然后它将打开 http://localhost/htdocs/ 位置。然后导航到您的 php 文件。它将相应地打开。
Just type LOCALHOST in your browser. then it will open the http://localhost/htdocs/ location. then navigate to your php file. It will open accordingly.