If PHP files get downloaded rather than executed on Ubuntu

you probably didn’t install libapache2-mod-php5:

 sudo apt-get install libapache2-mod-php5