Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP not interpreted, showing in view source

Tags:

php

apache

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>

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.

You can see the page.

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.

like image 758
Mark Avatar asked Jul 21 '12 21:07

Mark


People also ask

Why is my PHP code showing in browser?

You've written your first PHP program, but when you go to run it, all you see in your browser is the code—the program doesn't actually run. When this happens, the most common cause is that you are trying to run PHP somewhere that doesn't support PHP.

How do I know if PHP is running CGI?

Open the terminal prompt and then type the following commands. Login to the remote server using the ssh command. To check PHP version, run: php –version OR php-cgi –version.

Why is my PHP code not working?

Why won't my PHP code work? You have not setup the php interpreter correctly with your http server. If you are using apache2 .. then you need to setup PHP with apache. and uncomment LoadModel php5_module ….


1 Answers

You can install libapache2-mod-php5 using

apt-get install libapache2-mod-php5

Worked for me.

like image 190
Nvan Avatar answered Sep 19 '22 05:09

Nvan