The problem is the php file returns the php code itself in the browser without parsing it. So what did I miss?

Update: Staring phpfpm or nginx works fine but I think nginx isn't aware of phpfm at all, some link is missing perhaps? I checked nginx error logs but there is nothing related to php. I can't seem to figure out what is missing.

Have you reloaded nginx after changing the configuration? You can do that with sudo service nginx reload.

Nginx sets headers which cause the browser to cache pages. Make sure you're not seeing the cached version of the PHP page by pressing Ctrl + F5 (Firefox). Alternatively, use curl or wget to verify that the problem is not caused by your browser.
You'd better to follow the official sources on installing php-fpm on nginx.