Debian Sarge, PHP4 and Apache2.. why do you persecute me?

Oh FFS! Has anyone had a problem with Apache2 and PHP4 on Debian Sarge/Testing? I have a stock install of it with nothing unusual AFAICT but Firefox keeps trying to download and save php files instead of processing them. All the config files seem to be correctly set up. Files in mods-enabled/ are fine.
Why am I upset? I added the wp-newblog.php to WPMU SVN tonight, imported a chunk of code from install.php so it’s a one-step process, but I can’t test this thing to see if it works! It’s here as a WPMU snapshot but it won’t work out of the box. It needs an entry in .htaccess first, and bug fixing.

I’m off to relax, it’s been a long day.. zzzz

Much Later… I finally got it working again. I tried dpkg-reconfigure phpmyadmin but it didn’t update the config file with this error:

Not replacing deleted config file /etc/apache2/conf.d/phpmyadmin.conf

Following the clues from here I did the following:

apt-get remove –purge libapache2-mod-php4
apt-get remove –purge apache2
apt-get install libapache2-mod-php4 phpmyadmin

PHPMyAdmin now works fine, and hopefully wpmu will too!

Author: Donncha

Donncha Ó Caoimh is a software developer at Automattic and WordPress plugin developer. He posts photos at In Photos and can also be found on Google+ and Twitter.

22 thoughts on “Debian Sarge, PHP4 and Apache2.. why do you persecute me?”

  1. Did you check out the AddHandler line to make sure PHP is parsing the files, and the AddType to make sure that they’re being sent as the right type. Also check the LoadModule statements for PHP. If you’re lost, its all in the apache httpd.conf, and there are hundreds of tutorials on google for setting it all up.

  2. Make sure you have all the following lines somewhere in your httpd.conf (or in your conf.d/php.conf):

    LoadModule php4_module modules/

    # Cause the PHP interpreter to handle files with a .php extension.
    AddType application/x-httpd-php .php

    # Add index.php to the list of files that will be served as directory
    DirectoryIndex index.php

    Hope that helps.

  3. I have the Apache 2 config files correctly setup, and they worked fine for ages until a few weeks ago when I did an apt-get upgrade. If I can’t get Apache 2 to work, I’ll try Apache 1.3, there’s not real reason to use Apache 2 except that it was the default AFAIR.

  4. Hrm,

    I’ve only ever seen the ‘download’ for WP occurring once on my home testing server (which was Debian testing + apache2). This actually occurred after going from testing to unstable for me.

    It’s usually due to either missing libapache2-mod-php4, a php4 package missing due to a conflict resolution during the upgrade, or an Apache conf file that has been overwritten by dkpg/ apt-get. I now have a Ubuntu Hoary box that acts as my linux workstation and server..

    Firing up aptitude, and doing a search against “php” will cycle through the various php packages. It’s quite possible during the upgrade, something got broken (due to conflict resolution), so it is worth checking you have all the required packages.

    Simply replacing Apache 2 with 1.3 won’t fix the issue (by itself) as you will also need to install all the apache 1.3 associated php packages as well.

  5. You may have encountered same “entertaining” caching behaviour of the browser that I just did.

    It’s 5:18AM here. I just spent four hours trying to get similar setup going, just to find out that I’ve been getting the initial application/x-httpd-php file from disk cache instead of server itself. It got cached when I first tried to load the page, and there indeed was a configuration problem. After that every subsequent refresh just gave the php file from disk cache and asked if I’d like to save it. In total frustration I tried http://host/file.php instead of just http://host/ – and of course it worked. Five hours of solving a problem that was not.

  6. “You may have encountered same “entertaining” caching behaviour of the browser that I just did”

    YES! OMG! Cache caused this problem for me! I went absolutely CRAZY! Until I tried clearing my cache.


  7. Had a similar error, solved it using:
    When you upgrade Apache you have to install libapache2-mod-php4

    Apache 2 doesn’t always automatically update the php.ini files so that the related packages can be used with Apache The solution to this is to reconfigure the php4-pgsql and php4-mysql packages with:

    dpkg-reconfigure php4-pgsql php4-mysql

    with a smile

  8. erno: you’ve just saved me several hours of witch-hunting. Thank You.

    Keywords for google: apache2 directory index php4 debian sarge download x-httpd-php.

  9. I’m using php5 and I finally got it to load a page rather than the download manager – but it’s loading 404 page not found . . . Still, a change in error msg is as good as a rest. Thanks for getting me this far!

  10. Thanks, erno! I just spent a half hour fighting with the configuration only to discover that it was, indeed, your entertaining caching issue. Cheers!

  11. Thanks so much for posting this information out there. I just tried to do a side-by-side install of PHP4 and PHP5 unintentionally and it blew up my install. The comments here saved my hide! Props

  12. I battled php5 apache2 mysql, and finally I found that
    LoadModule php5_module /usr/lib/apache2/modules/
    was not added to apache2.conf automatically by the
    apt-get install libapache2-mod-php5
    procedure. Maybe this is a trivial fact that everyone but me would know beforehand? Anyway, adding the LoadModule line above fixed my problems.
    Also, that web browser caching deal sounds like a nasty little way to obfuscate any headway that someone might be making while trying to get this all working.

  13. Thanks Donncha!

    dpkg-reconfigure phpmyadmin actually worked out for me without a single error… Fortunatelly. I´ve had this problem since yesterday but now everything seems ok.

Leave a Reply