Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

migrated from Apr 2 '12 at 5:12

This question came from our site for professional and enthusiast programmers.

anything in the error log? – dldnh Apr 2 '12 at 0:59

One common reason is that you are using the PHP short open tag <? but PHP has short_open_tag disabled.

share|improve this answer
That's true, but I'm not using short tags. – Pete Johnson Apr 1 '12 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 "\.phps$">
        SetHandler application/x-httpd-php-source
    # 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
share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.