Upgrading to Ubuntu 10.04 Breaks Serving php from Home Directories

I upgraded to Ubuntu 10.04 this morning and immediately noticed I could no longer serve php applications from my home directory. When I tried to visit one of my projects, http://test.local for example, Firefox opened a download dialog with a message similar to “You have chosen to open index.phtml . . .”

After quite a bit of googling and forum searching, I went to Twitter asking for help. Many thanks to @sypherNL for helping me resolve this one.

It seems that something has changed in /etc/apache2/mods-enabled/php5.conf. If you’re experiencing this same issue, check your php5.conf and see if it matches mine.

<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>

If your php5.conf file looks like the one above, simply comment out the

<IfModule mod_userdir.c>

lines as instructed. Once that’s done, restart apache with the following command:

sudo /etc/init.d/apache2 reload

Clear your browser’s cache and try to visit your site again. I didn’t think the fix took at first, but after clearing cache everything worked just fine.

Related Links

6 thoughts on “Upgrading to Ubuntu 10.04 Breaks Serving php from Home Directories

  1. magic. With a headless server I was wondering what my next move was going to be!

    Many thanks for saving me many hours of googling at midnight!

  2. Thanks! Had the exact same problem on my work machine after upgrading to 10.04 over the weekend. Now I can go back to looking busy ;)

  3. Now about reviewing the op’s post we like the above as it’s correct so it’s pleasant to read from a person thats blogging info such as this online

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">