Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么HTML文件会正确加载,而PHP文件不会?_Php_Html - Fatal编程技术网

为什么HTML文件会正确加载,而PHP文件不会?

为什么HTML文件会正确加载,而PHP文件不会?,php,html,Php,Html,我有两个简单的测试文件,一个是显示简单消息的基本HTML文档,另一个是执行相同操作的PHP文档 如果我使用如下URL访问HTML文档,它会正确显示: sample.com/test.html sample.com/test.php 如果我以类似的方式访问PHP文件,它也会正确显示: sample.com/test.html sample.com/test.php 从子目录访问HTML文件也可以正常工作: sample.com/somedirectory/test.html 但是,以类似方

我有两个简单的测试文件,一个是显示简单消息的基本HTML文档,另一个是执行相同操作的PHP文档

如果我使用如下URL访问HTML文档,它会正确显示:

sample.com/test.html
sample.com/test.php
如果我以类似的方式访问PHP文件,它也会正确显示:

sample.com/test.html
sample.com/test.php
从子目录访问HTML文件也可以正常工作: sample.com/somedirectory/test.html

但是,以类似方式访问PHP页面不起作用:

sample.com/somedirectory/test.php
它会产生以下错误:

内部服务器错误

服务器遇到内部错误或配置错误,无法完成您的请求

请与服务器管理员联系,webmaster@samplehs.pltwcs.org并告知他们错误发生的时间,以及您可能采取的任何可能导致错误的措施

有关此错误的详细信息,请参阅服务器错误日志

此外,尝试使用ErrorDocument处理请求时遇到404 Not Found错误` 编辑 以下是HTML代码:


根据错误
文件“/home/username/public\u html/somedirectory/test.php”可由组写入
您的服务器正在使用类似suphp的东西,您需要从命令行中删除组:
chmod go-w/home/username/public\u html/somedirectory/test.php
的写入权限。

您必须将php文件的权限设置为
644
,文件夹的权限设置为
755
,因为您的服务器启用了
suEXEC

您应该从终端运行
chmod 644 test.php
或使用任何FTP客户端设置权限


服务器错误日志中显示了什么?请发布一些代码,以便我们可以尝试查找我们需要查看日志的错误。请粘贴以下命令的输出:
tail-n100/var/log/apache2/error.log
如sjagr所述,将权限设置为644也可以,但会重置您拥有的任何“其他权限”。实际上,因为它使用的是suphp/suexec,所以您可以将它们设置为600,这样web服务器上的其他人就无法查看它们(并且应该,至少对于任何包含“敏感”信息的内容——数据库密码等)
[Wed Dec 18 12:58:08 2013] [error] [client 71.222.168.54] File does not exist: /home/username/public_html/500.shtml
[Wed Dec 18 12:58:08 2013] [error] [client 71.222.168.54] SoftException in Application.cpp:256: File "/home/username/public_html/somedirectory/test.php" is writeable by group