简体   繁体   English

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

[英]On AWS EC2 Linux RHEL all PHP files are executing, except for index.php

I am lost on this one. 我迷失了这一点。

I have setup an AWC EC2 RHEL server, and installed php and apache. 我已经安装了AWC EC2 RHEL服务器,并安装了php和apache。 Everything seems to work except for the fact that the index.php file will not execute. 除了index.php文件不会执行之外,其他一切似乎都可以正常工作。 All other *.php files will work if I call them directly. 如果我直接调用所有其他* .php文件,它们将起作用。

index.php contains: index.php包含:

<?php echo "test"; ?>

in /etc/httpd/conf/httpd.conf I have the settings: /etc/httpd/conf/httpd.conf我有以下设置:

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

Although if I remove the index.php still does not work. 虽然如果删除index.php仍然无法正常工作。

I have the permissions on index.php as -rw-r--r-- ec2-user ec2-user 我对index.php拥有-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. 我不确定在这里看到什么其他信息会有用,因为除index.php之外所有其他php文件都可以工作。 (eg: if I call /index.php outputs nothing, if I move index.php to index2.php and call /index2.php outpus test ) (例如:如果我调用/index.php输出任何内容,如果我将index.php移到index2.php并调用/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. 我现在意识到调用index.php文件检查访问日志时出现500个内部服务器错误。

"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. 同样,将文件名更改为index.php以外的任何名称(例如: index2.php )将正确执行文件。

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. 我尝试将权限更改为各种变体,包括777、755、655、644、664等,甚至尝试将所有者更改为apache。 no luck. 没运气。

AWS EC2 RedHat Web Server inner links are not working. AWS EC2 RedHat Web Server内部链接不起作用。 Solution

# Possible values for the Options directive are "None", "All",
# or any combination of:
# Note that "MultiViews" must be named explicitly --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
AllowOverride none 

new value should change to AllowOverride all 新值应更改为AllowOverride all

Try to configure selinux in permissive or disabled mode. 尝试以许可或禁用模式配置selinux。

I had the same problem. 我有同样的问题。 I was trying to install moodle and failed. 我试图安装Moodle,但失败了。 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. 我将selinux配置为宽松,以查看这是否是根本原因,并且确实可以安装。

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. 我的问题是,我已经以普通用户的名义在他的主目录下打开了moodle存档(moodle ... tar.gz),并将其移至apache的DocumentRoot。 This got the selinux content field to be wrong. 这使selinux内容字段错误。

I have enable selinux and opened the tar.gz archive directly under DocumentRoot (/var/www/html). 我启用了selinux,并直接在DocumentRoot(/ var / www / html)下打开tar.gz存档。 This gave the right content attribute to the files (httpd_sys_content_t). 这为文件(httpd_sys_content_t)提供了正确的内容属性。 I was able to run moodle with selinux enabled. 我能够启用selinux来运行moodle。

Mosh 莫什

Permissions needs to be set to read by Apache users. 需要将权限设置为由Apache用户读取。 Current permissions doesn't allows it to read the file as Apache User. 当前权限不允许它以Apache用户身份读取文件。

Also it would be good to check what error you are getting in Apache Logs, it should be "403 Forbidden" if I am not wrong. 另外,最好检查一下Apache日志中出现的错误,如果我没有记错的话,应该为“ 403 Forbidden”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM