Apache2: php file getting downloaded instead?

After having installed all the necessary packages on my fresh Ubuntu, while testing different configurations I came across this problem where the php file was being offered for download when tried to execute via browser! That is, whenever I tried to open a php script through browser, the file was getting downloaded, instead of being executed. If you are a LAMP-fan (like me), you might come across this problem in future or perhaps you are facing it now and have reached here.. 😉 The problem is straight forward :

“the apache server is not able to execute the requested php script (even though the core Apache & PHP packages are installed) and hence offering it for download”

Fortunately, in my case, the resoluton turned out to be simple. While installing php+apache, I missed out the php module for apache, which basically enables apache to handle php scripts. So, I installed it, restarted the apache server and the problem just got resolved!

$ sudo apt-get install libapache2-mod-php5

$ sudo /etc/init.d/apache2 restart

$ find /etc/apache2/ | grep php