If PHP files are getting downloaded instead of executing, make sure that PHP type is added to Apache

AddType application/x-httpd-php .php

Restart the web server once the changes are done and try to open the web page again.

$ sudo apachectl -k restart