I am new to PHP, and relatively new to Apache.
For my server, I am using a raspberry pi running Ubuntu MATE, which (as far as I know) is just Ubuntu with a different desktop environment. I have PHP installed, and the file I’m serving is a .php file, NOT html.
I am trying to execute PHP code on my test page, which is just served locally. I know that I need to edit the config file for Apache in order for it to run, but I don’t know how; all of the various answers and articles I have looked at the past few days are either for Windows or for a much older version of Apache. I have tried many of them, and they all either result in nothing changing or an error when trying to restart Apache.
The PHP code I’m using looks like this:
<!DOCTYPE html>
<html>
<body>
<?php
echo "Hello!";
?>
</body>
</html>
Looking at the inspector in Firefox, the PHP code is commented out, a clear indication that it is not being executed.
Thank you for your help.
2
Answers
It is possible that,
libapache2-mod-php7.x
moduleBelow will help you
Example in my case
I had this same problem,Eventhough my apache was running it just rendered raw codes on the browser; after debugging it manually and searching through the internet I finally got it solved. About two simple things fixed mine "though they weren’t simple before I did them:)".
Btw I am running running PHP v7.4.3 on Ubuntu 20.04.
If you haven’t installed PHP or Apache on your machine; you can check out this site for how to go about it for PHP version 7.4.3 Linuxhint