PHP Not Parsing on Debian / Ubuntu server with Apache2

My friend Marshall was recently having issues getting PHP5 installed and working on his Ubuntu server, which is a Debian based distribution.

We updated all the packages involved…Apache2, php5, libapache2-mod-php5, made sure the module was installed, restarted Apache2, etc. Nothing worked.

It turns out that the default php5.conf configuration for Debian / Ubuntu’s packages are using an incorrect syntax. Edit /etc/apache2/mods-available/php5.conf to reflect:

<FilesMatch \.php$>
  SetHandler application/x-httpd-php
</FilesMatch>

…instead of…

AddType application/x-httpd-php .php

Special thanks to this Apache wiki article for pointing this out:

http://wiki.apache.org/httpd/DebianPHP

I’m just posting this solution here for all the other nerds having the same issue that aren’t finding this article in Google.



6 Responses to PHP Not Parsing on Debian / Ubuntu server with Apache2
  1. Dante Elrik
    June 22, 2010 | 11:14 pm

    That was very helpful; I’d been trying to figure this issue out for nearly an hour before I stumbled upon your site.

    Thanks

  2. admin
    June 25, 2010 | 1:56 am

    Thats why I posted it. I’m glad it helped you fix it instead of taking many hours more.

  3. Flic
    August 15, 2010 | 12:59 am

    Thank you very much! I have been tearing my hair out for hours (not to mention uninstalling and reinstalling software) trying to work this out and although your solution didn’t exactly match my problem, it told me where I should be looking. Pretty straightforward from there. Now if only Google would return this higher up in its results instead of 20 sites giving the same installation instructions…

  4. eZH
    October 29, 2010 | 1:43 am

    Thanks a lot.
    damn packagers, they ruin everything

  5. TonyC
    November 4, 2010 | 4:39 am

    I love you! I’ve been scouring all over the internet looking for this bugger! Like I somehow had php running correctly one one of my vhosts but when my client wanted to get add more sites, I ran into this problem again.. Darn just knew it had to be a bug with the version of Ubuntu!

  6. dh
    August 2, 2011 | 12:43 am

    After long search and a lot of tries, this worked for my sandbox vserver as well. Glad I don’t have to bother our admin again. :)
    Thanks a lot guys. Good job.

Leave a Reply

Wanting to leave an <em>phasis on your comment?

Trackback URL http://www.redconfetti.com/2010/02/php-not-parsing-on-debian-ubuntu-server-with-apache2/trackback/