If the page only shows the code that's because the PHP interpreter isn't running. Look at your
httpd.conf (Apache configuration file) and look if the line that says 'LoadModule php5_module' isn't commented with
# sign.
Also, look for 'Listen' should say 'Listen 80' so you can put simply
http://localhost/ on the browser. If the server is running on another port instance e.g. the line shows 'Listen 8080', put on the browser
http://localhost:8080/. This is a more uncommon issue.
If that doesn't make any change, maybe the PHP module isn't installed. I suggest to use a pre-configured package software with Apache/PHP/MySQL like xampp or mamp.
Make a new file on the root folder of your web server, 'test.php'. Add on the content:
Then on the browser access to
http://localhost/test.php
It should display the PHP version and installed modules.
Well this is to manage sort of troubles with PHP, I haven't seen the previous page and the year