未解释PHP,在视图源中显示 [英] PHP not interpreted, showing in view source

查看:100
本文介绍了未解释PHP,在视图源中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望这对于开始运行php代码以及解决当前问题将是一个有用的页面,我有一些非常简单的代码,如下所示:

I'm hoping that this will be a useful page for getting started running php code as well as solve the current problem I'm having some very simple code as follows:

<html>
<head>
<title> Practice</title></head>
<body>
This is HTML
<?php
echo "This is PHP";
?>
</body>
<html>

此文件已上传到运行apache的ec2网站上.该代码不会被解释,当您查看页面源代码时,它会显示php代码.

This is uploaded on an ec2 website which has apache running. The code isn't interpreted, and when you view source of the page it shows the php code.

您可以看到页面.

有什么想法吗? php代码是如此基础,以至于我认为它可能与apache配置有关.请让我知道您需要的其他任何信息,我会提供,希望能告诉我如何获得它.

Any ideas? The php code is so basic that I think it might have to do with the apache configuration. Please let me know any additional information you need and I'll provide it, hopefully tell me how to get it to.

推荐答案

您确定已安装php吗?如果是,则需要确保apache将.php文件与php处理程序相关联.在/etc/apache/apache.conf

Are you sure you have php installed? If it is you need to make sure that apache is associating .php files with the php handler. Look for an entry similar to the following in /etc/apache/apache.conf

 LoadModule php5_module modules/libphp5.so

 application/x-httpd-php        php php5

更改文件后,您需要通过sudo service httpd restart

upon changing the file you will need to restart apache via sudo service httpd restart

这篇关于未解释PHP,在视图源中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆