Apache not executing PHP code – just renders the as it is

This is the issue when you are having a fresh install of apache usually.
You need to tell apache should handle the extensions so that it could process them accordingly.
On you apache path, go to the config and open the httpd.conf file
and add the following

AddType application/x-httpd-php .php

Also, make sure the Module for php is installed as well..
in your httpd.conf file, search for:

#LoadModule php5_module libexec/apache2/libphp5.so

and, of course, uncomment that to enable php.