我正在使用 Amazon EC2、CentOS 7 x64_86、1GB RAM。
(1)运行命令
php -v
结果
PHP 7.0.24 (cli) (built: Sep 30 2017 10:10:28) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
(2)运行命令
httpd -v
结果
Server version: Apache/2.4.6 (CentOS)
Server built: Oct 19 2017 20:39:16
(3)运行命令
vi /etc/httpd/conf.d/welcome.conf
结果
#
# This configuration file enables the default "Welcome" page if there
# is no default index page present for the root URL. To disable the
# Welcome page, comment out all the lines below.
#
# NOTE: if this file is removed, it will be restored on upgrades.
#
#<LocationMatch "^/+$">
# Options -Indexes
# ErrorDocument 403 /.noindex.html
#</LocationMatch>
<Directory /usr/share/httpd/noindex>
AllowOverride None
Require all granted
</Directory>
Alias /.noindex.html /usr/share/httpd/noindex/index.html
Alias /noindex/css/bootstrap.min.css /usr/share/httpd/noindex/css/bootstrap.min.css
Alias /noindex/css/open-sans.css /usr/share/httpd/noindex/css/open-sans.css
Alias /images/apache_pb.gif /usr/share/httpd/noindex/images/apache_pb.gif
Alias /images/poweredby.png /usr/share/httpd/noindex/images/poweredby.png
错误
和
如何修复?
答案1
我不确定您从哪里获得 PHP,因为 CentOS 7 附带的版本是 5.4.16。无论如何,stockphp
包会安装 Apache 的配置,以便*.php
文件通过 PHP 解释器进行传输(因此它们不只是返回源代码)。您需要将类似以下内容添加到 Apache 配置中:
LoadModule php5_module modules/libphp5.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
这是基于标准php
包配置的。如果您自己编译了 PHP,则需要对其进行调整以适应。