繁体   English   中英

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

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

我迷失了这一点。

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

index.php包含:

<?php echo "test"; ?>

/etc/httpd/conf/httpd.conf我有以下设置:

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

虽然如果删除index.php仍然无法正常工作。

我对index.php拥有-rw-r--r-- ec2-user ec2-user

我不确定在这里看到什么其他信息会有用,因为除index.php之外所有其他php文件都可以工作。 (例如:如果我调用/index.php输出任何内容,如果我将index.php移到index2.php并调用/index2.php outpus test

为什么会这样呢?

编辑

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

"GET /index.php HTTP/1.1" 500

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

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

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

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

AWS EC2 RedHat Web Server内部链接不起作用。

# 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 

新值应更改为AllowOverride all

尝试以许可或禁用模式配置selinux。

我有同样的问题。 我试图安装Moodle,但失败了。 我上面有同样的错误。

我将selinux配置为宽松,以查看这是否是根本原因,并且确实可以安装。

我的问题是,我已经以普通用户的名义在他的主目录下打开了moodle存档(moodle ... tar.gz),并将其移至apache的DocumentRoot。 这使selinux内容字段错误。

我启用了selinux,并直接在DocumentRoot(/ var / www / html)下打开tar.gz存档。 这为文件(httpd_sys_content_t)提供了正确的内容属性。 我能够启用selinux来运行moodle。

莫什

需要将权限设置为由Apache用户读取。 当前权限不允许它以Apache用户身份读取文件。

另外,最好检查一下Apache日志中出现的错误,如果我没有记错的话,应该为“ 403 Forbidden”。

暂无
暂无

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

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