PHP not running on Apache server

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>
echo "Hello!";

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.

did you install the php and libapache2-mod-php packages? this small code with give you info about your php install, save it as /var/www/html/info.php and test with http://localhost/info.php

<?php phpinfo() ?>

I installed both; running the install for either shows this, plus I can find the Apache things in /etc/php/. However, Apache doesn’t seem to have recognized it. I can’t run phpinfo(); because I can run PHP obviously, but running php -v shows that I am running 7.2 for Ubuntu. I might try updating everything to make sure I have the latest release, but I’m pretty sure that the problem lies in apache2.conf, where I can’t find a single reference to PHP. Thank you for your help though.

I followed this guide ... and look in /var/log/apache2/error.log for issues.

I fixed it. It turned out that I needed to enable PHP before using it. It works perfectly now.