I've just install Apache22, PHP 5 with Apache module, and MySQL. The Apache conf file has the PHP LoadModule line, but it still displays the PHP source code. Are there any other reasons why this happens?
3 Answers
One common reason is that you are using the PHP short open tag <? but PHP has short_open_tag disabled.
-  That's true, but I'm not using short tags.Pete Johnson– Pete Johnson2012-04-01 14:27:47 +00:00Commented Apr 1, 2012 at 14:27
I think you may need to set an application type, so it knows to use the php module based on a file extension or something.
I don't use FreeBSD, so I don't know the installation process. On Windows and Ubuntu/Linux Mint this is done automatically.
This is what I have in a file called php5.conf (that's just how it's organized in Ubuntu), but this can be just put in your http.conf anywhere after your load module line.
<IfModule mod_php5.c> <FilesMatch "\.ph(p3?|tml)$"> SetHandler application/x-httpd-php </FilesMatch> <FilesMatch "\.phps$"> SetHandler application/x-httpd-php-source </FilesMatch> # To re-enable php in user directories comment the following lines # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it # prevents .htaccess files from disabling it. <IfModule mod_userdir.c> <Directory /home/*/public_html> php_admin_value engine Off </Directory> </IfModule> </IfModule> The simplest solution is to add a line:
AddType application/x-httpd-php .php in httpd.conf. The most correct solution is described in the response of Gohn67.
