PHP not working on Apache2 Server

I was working on my MacOS and apache was not executing PHP. It took me a hot minute but I came across a working solution on StackOverflow. Here is the link to the solution for posterity:

The short version of the long answer on that page is:

Simply needed to enable php in apache:
sudo nvim /etc/apache2/httpd.conf
uncomment the following line
#LoadModule php7_module libexec/apache2/
then restart apache
sudo apachectl restart