PHP文件正在下载而不是在网站

时间:2017-02-21 14:30:43

标签: php apache amazon-ec2 httpd.conf php-7

所以我在亚马逊Linux服务器上安装了Php70 *,并安装了apache(httpd),当我在浏览器上查看php页面时,它会下载php文件,而不是在浏览器上显示。

我尝试了不同的浏览器,清除缓存,检查我的php文件的权限和错误。

这是我在我的系统上所拥有的希望它有所帮助;还有什么我可能会失踪的?任何帮助表示赞赏。

(我有一个名为“phpinfo.php”的简单php文件,其中包含

在终端的ec2实例上,我可以成功地执行php phpinfo.php

php -v
PHP 7.0.14 (cli) (built: Jan 18 2017 19:13:23) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.14, Copyright (c) 1999-2016, by Zend Technologies

httpd -v
Server version: Apache/2.4.25 (Amazon)
Server built:   Jan 19 2017 16:55:49

我安装了所有php70软件包:

sudo yum list installed php70*
Loaded plugins: priorities, update-motd, upgrade-helper
Installed Packages
php70.x86_64                  7.0.14-1.20.amzn1                    @amzn-updates
php70-bcmath.x86_64           7.0.14-1.20.amzn1                    @amzn-updates
php70-cli.x86_64              7.0.14-1.20.amzn1                    @amzn-updates
php70-common.x86_64           7.0.14-1.20.amzn1                    @amzn-updates
php70-dba.x86_64              7.0.14-1.20.amzn1                    @amzn-updates
php70-dbg.x86_64              7.0.14-1.20.amzn1                    @amzn-updates
php70-devel.x86_64            7.0.14-1.20.amzn1                    @amzn-updates
php70-embedded.x86_64         7.0.14-1.20.amzn1                    @amzn-updates
php70-enchant.x86_64          7.0.14-1.20.amzn1                    @amzn-updates
php70-fpm.x86_64              7.0.14-1.20.amzn1                    @amzn-updates
php70-gd.x86_64               7.0.14-1.20.amzn1                    @amzn-updates
php70-gmp.x86_64              7.0.14-1.20.amzn1                    @amzn-updates
php70-imap.x86_64             7.0.14-1.20.amzn1                    @amzn-updates
php70-intl.x86_64             7.0.14-1.20.amzn1                    @amzn-updates
php70-json.x86_64             7.0.14-1.20.amzn1                    @amzn-updates
php70-ldap.x86_64             7.0.14-1.20.amzn1                    @amzn-updates
php70-mbstring.x86_64         7.0.14-1.20.amzn1                    @amzn-updates
php70-mcrypt.x86_64           7.0.14-1.20.amzn1                    @amzn-updates
php70-mysqlnd.x86_64          7.0.14-1.20.amzn1                    @amzn-updates
php70-odbc.x86_64             7.0.14-1.20.amzn1                    @amzn-updates
php70-opcache.x86_64          7.0.14-1.20.amzn1                    @amzn-updates
php70-pdo.x86_64              7.0.14-1.20.amzn1                    @amzn-updates
php70-pdo-dblib.x86_64        7.0.14-1.20.amzn1                    @amzn-updates
php70-pecl-apcu.x86_64        5.1.5-2.2.amzn1                      @amzn-main   
php70-pecl-apcu-devel.x86_64  5.1.5-2.2.amzn1                      @amzn-main   
php70-pecl-igbinary.x86_64    1.2.2-0.1.20151217git2b7c703.5.amzn1 @amzn-main   
php70-pecl-igbinary-devel.x86_64
                          1.2.2-0.1.20151217git2b7c703.5.amzn1 @amzn-main   
php70-pecl-imagick.x86_64     3.4.2-1.4.amzn1                      @amzn-main   
php70-pecl-imagick-devel.x86_64
                          3.4.2-1.4.amzn1                      @amzn-main   
php70-pecl-memcache.x86_64    3.0.9-0.4.20160311git4991c2f.8.amzn1 @amzn-main   
php70-pecl-memcached.x86_64   3.0.0-0.1.20160217git6ace07d.2.amzn1 @amzn-main   
php70-pecl-oauth.x86_64       2.0.2-1.2.amzn1                      @amzn-main   
php70-pecl-ssh2.x86_64        1.0-5.16.amzn1                       @amzn-main   
php70-pecl-uuid.x86_64        1.0.4-7.1.amzn1                      @amzn-main   
php70-pecl-yaml.x86_64        2.0.0-1RC8.3.amzn1                   @amzn-main   
php70-pgsql.x86_64            7.0.14-1.20.amzn1                    @amzn-updates
php70-process.x86_64          7.0.14-1.20.amzn1                    @amzn-updates
php70-pspell.x86_64           7.0.14-1.20.amzn1                    @amzn-updates
php70-recode.x86_64           7.0.14-1.20.amzn1                    @amzn-updates
php70-snmp.x86_64             7.0.14-1.20.amzn1                    @amzn-updates
php70-soap.x86_64             7.0.14-1.20.amzn1                    @amzn-updates
php70-tidy.x86_64             7.0.14-1.20.amzn1                    @amzn-updates
php70-xml.x86_64              7.0.14-1.20.amzn1                    @amzn-updates
php70-xmlrpc.x86_64           7.0.14-1.20.amzn1                    @amzn-updates
php70-zip.x86_64              7.0.14-1.20.amzn1                    @amzn-updates

我看到有人提到将/etc/httpd/conf/httpd.conf文件更改为包含addtype / handler,所以这就是我所拥有的:

grep -n "php" /etc/httpd/conf/httpd.conf
54:LoadModule php7_module   modules/libphp-7.0.so
163:    DirectoryIndex index.html index.php
175:    SetHandler application/x-httpd-php
287:    AddType application/x-httpd-php .php
288:    AddType application/x-httpd-php-source  .phps
301:    AddHandler php7-script  .php
302:    AddHandler application/x-httpd-php .phps
303:    AddHandler application/x-httpd-php .php

我也有short_open_tags = on以防万一:

grep short_open_tag php-7.0.ini
; short_open_tag
short_open_tag = On

grep short_open_tag php.ini
; short_open_tag
short_open_tag = On

0 个答案:

没有答案