How can I prevent users from seeing my PHP source code?

Solution 1:

Apache wasn't "deleted" or "off", or else you wouldn't have been able to see the php source either. You can add the below codeblock to turn off serving .php files when php isn't loaded:

<IfModule !mod_php4.c>
    <FilesMatch "\.php$">
        Order allow,deny
        Deny from all
        Allow from none
    </FilesMatch>
</IfModule>

Solution 2:

To answer the poster's comment posted as an answer, one of the following should work for the PHP5 module, depending on how it's installed (Sander Rijken's modified):

<IfModule !mod_php.c>
    <FilesMatch "\.php$">
        Order allow,deny
        Deny from all
        Allow from none
    </FilesMatch>
</IfModule>

Or,

<IfModule !mod_php5.c>
    <FilesMatch "\.php$">
        Order allow,deny
        Deny from all
        Allow from none
    </FilesMatch>
</IfModule>

Include only one of these two snippets, depending on which works for your configuration.