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.

  • 写回答

3条回答 默认 最新

  • dsklfsdlkf1232 2016-10-14 07:57
    关注

    Try to configure selinux in permissive or disabled mode.

    I had the same problem. I was trying to install moodle and failed. I got the same error above.

    I configured selinux to permissive to see if this is the root cause and indeed I was able to install.

    My problem was that I have opened moodle archive (moodle...tar.gz) as a regular user under his home directory and moved it to apache's DocumentRoot. This got the selinux content field to be wrong.

    I have enable selinux and opened the tar.gz archive directly under DocumentRoot (/var/www/html). This gave the right content attribute to the files (httpd_sys_content_t). I was able to run moodle with selinux enabled.

    Mosh

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题