doupingtang9627
2014-08-14 16:25
浏览 104
已采纳

在AWS EC2 Linux RHEL上,除index.php外,所有PHP文件都在执行

I am lost on this one.

I have setup an AWC EC2 RHEL server, and installed php and apache. Everything seems to work except for the fact that the index.php file will not execute. All other *.php files will work if I call them directly.

index.php contains:

<?php echo "test"; ?>

in /etc/httpd/conf/httpd.conf I have the settings:

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

Although if I remove the index.php still does not work.

I have the permissions on index.php as -rw-r--r-- ec2-user ec2-user

I am not sure what other information would be useful here seeing as all other php files work except for the index.php. (eg: if I call /index.php outputs nothing, if I move index.php to index2.php and call /index2.php outpus test)

Any thoughts as to why this may be happening?

EDIT

I am now realizing there is a 500 internal server error when the index.php file is called checking the access logs.

"GET /index.php HTTP/1.1" 500

Maybe that will help point in the right direction? I am still unclear how to solve this issue. Again, changing the name of the file to anything other than index.php (eg: index2.php) will execute the file correctly.

Also, after enabling error reporting I am getting this error:

PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0

PHP Fatal error: Unknown: Failed opening required '/var/www/html/index.php' (include_path='.:/usr/share/pear:/usr/share/php') in Unknown on line 0

I have tried changing permissions to all sorts of variants including 777, 755, 655, 644, 664, etc... even tried changing owner to apache. no luck.

图片转代码服务由CSDN问答提供 功能建议

我迷失了这个。

我已经设置了AWC EC2 RHEL服务器,并安装了php和apache。 除了index.php文件不会执行之外,一切似乎都有效。 如果直接调用它们,所有其他* .php文件都可以工作。

index.php包含:

 &lt;?php echo“ 测试”;   /etc/httpd/conf/httpd.conf 中的&gt; 
   
 
 

我有以下设置: \ n

 &lt; IfModule dir_module&gt; 
 DirectoryIndex index.html index.php 
&lt; / IfModule&gt; 
   
 
 

虽然我删除索引 .php仍然无效。

我对 index.php 的权限为 -rw-r - r-- ec2-user ec2 -user

我不确定除了index.php之外,其他所有其他php文件都能正常工作。 (例如:如果我调用 /index.php 输出什么,如果我将 index.php 移动到 index2.php 并调用 / index2.php outpus test

有关为什么会发生这种情况的任何想法?

< strong>编辑

我现在意识到当调用index.php文件检查访问日志时,有500个内部服务器错误。

“GET /index.php HTTP / 1.1”500

也许这有助于指出正确的方向? 我还不清楚如何解决这个问题。 同样,将文件名更改为 index.php 以外的任何名称(例如: index2.php )将正确执行文件。

此外,启用错误报告后,我收到此错误:

PHP警告:未知:无法打开流:第0行的未知权限被拒绝

PHP致命错误:未知:未能打开所需的'/var/www/html/index.php'(include_path ='。:/ usr / share / pear:/ usr / share / php')在第0行的Unknown中

我尝试将权限更改为各种变体,包括777,755,655,644,664等。 甚至尝试将所有者改为apache。 没有运气。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题