Notes when upgrading to PHP5

I upgraded one of my servers to PHP5 this morning. Two things to watch out for:

  • The location of your php.ini may have changed. It’s probably now in /etc/php5/apache2/. You need to copy over any changes from your old one.
  • Update your libraries too such as the mysql client and the gd library. Don’t forget you can delete the old ones. apt-get install php5-mysql php5-gd will do the job of installing, the old packages have a php4 prefix.
  • WP-Cache doesn’t like PHP5 much. If you see a blank page after upgrading to PHP5, then hit reload and it loads, then WP-Cache needs to be modified. Leroy has the fix, open wp-cache-phase2.php in your wp-cache folder and change ob_end_clean() to ob_end_flush(). SImple as that!

The reason for the upgrade? I wanted to install the gd extension, but after lots of fun upgrading everything my browser tried to download every page, complaining that it was a phtml file. I chose the upgrade to PHP5 to fix it!

And finally, the reason for gd, was to get the heatmap in this wordpress click tracking plugin working. It’s like Crazy Egg and it works well, but I couldn’t get it to display a heatmap for any page other than the front page. Some of the comments on Daily Blog Tips where I found it are hilarious. They completely miss the point of using a heatmap!

14 thoughts on “Notes when upgrading to PHP5

  1. Odd that you’d have issues with Wp-cache. I’ve been using it on my servers for quite some time and they all run php5 …


  2. Isn’t the location of php.ini distro dependent? I know it’s in /etc/php5/apache2/ under Debian/Ubuntu but under one of our Red Hat servers it’s /etc/php.ini, and that didn’t change with an upgrade to PHP 5.

  3. Over-generalising a little in some parts there:

    The location of your php.ini may have changed. It’s probably now in /etc/php5/apache2/

    apt-get install php5-mysql php5-gd will do the job of installing…

    Maybe so on Debian or a Debian-based system (including Ubuntu), but certainly not the case for all Linux distros, or other OSes.


  4. Hello

    Nice post there. I am facing a problem if you could help me. I am using GoDaddy’s hosting, they say .php files will run PHP4 and .php5 will run PHP5.

    That means my wordpress blog is running on PHP4, how can I run it on PHP5???

  5. @Arpit – ask your host.

    It sounds like you’d have to rename all the .php files to .php5 (which would involve changing various parts of the WordPress code too – not recommended). It might be possible to use a .htaccess file to make .php files in your WP dir execute with PHP5, but I doubt it.

    More to the point, if WP is working nicely on PHP4 for you, do you really need it to run with PHP5?

  6. I just wanted to use XML output from Youtube APIs, someone told me to use PHP5. Can I use PHP4 to parse XML ??

    (I am new to PHP community, I’ve worked on .NET before)

  7. I’ve shied away from using the packaged versions of php, since they don’t update fast enough when php security holes are plugged upstream, so I compile my own.

    Doing this eliminates the hassle of your ini file moving around, and lets you hand tune your php installation.

  8. I had trouble with PHP 5.2.x, but have a bunch of wordpress sites running on PHP 5.1.4 and a couple on 5.1.6 with no problems at all. Several of the sites use wp-cache and were fine after the wp-cache-phase2.php patch. Both servers are Apache 1.1.37 and MySQL 5.0.27. No idea if that has any effect on WP.

Leave a Reply

%d bloggers like this:

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.