Navigate to: /etc/apache2/httpd.conf and search for php. You should see:
#LoadModule php7_module libexec/apache2/libphp7.so
Remove the # which is uncommenting that line. Save the file and then restart Apache with the command:
sudo apachectl restart
As a quick test, if you place a small php file in your web server directory (/Library/WebServer/Documents/) you should be able to run it.
<?php echo "Hello, world!"; ?>
The other option is to run the command: