Upgrade PHP

For security reasons, we are recommending that PHP FogBugz users upgrade to PHP 4.3.10 if they have any mailboxes set up in FogBugz. This is a short guide to upgrading your PHP version with minimum FogBugz downtime.

Packages or source?

If prebuilt packages exist for the version of PHP you want, and you are using a Linux install that is up-to-date enough that using them would not be a major undertaking, then by all means use them. For instance, right now rpms for PHP 4.3.10 are available from Fedora's Download Site, and Debian packages are available via apt-get. Just remember to get the php-imap and php-mysql packages as well as the php one; these are extensions you need to run FogBugz. This document will not cover package-based install, but you can find some discussion of it in our guide to Getting Ready (for FogBUGZ for Unix).

If, however, you are running an older version of Linux, or for some other reason need to build php from source, then read on.

Get the source

Start by downloading the desired php source from http://www.php.net/downloads.php into your build directory (e.g. /usr/local/src).

Then:

cd [builddir]
bzip2 -d php-4.3.10.tar.bz2
tar xvf php-4.3.10.tar

Now you just need to make sure you have a couple of other tools and libraries to build PHP.

Get the right version of Apache

PHP 4.3.10 requires Apache version 2.0.44 or higher.

You can check your Apache server version with one of the following commands:

apachectl -v (for Apache 2.x)

or

apachectl status (for Apache 1.x)

If your version of Apache is too low, you will not be able to install PHP 4.3.10 without upgrading Apache as well. This can be more intrusive than rebuilding just PHP - remember to back up your configuration files (e.g. httpd.conf) before upgrading Apache by either package or source, and remember that your new Apache version may not be compatible with your old libphp4.so, so your FogBugz may be down until you finish upgrading PHP.

Find apxs

We need apxs (the APache eXtenSion tool) to build the libphp4.so shared object for Apache

Try:

locate apxs

If this does not find apxs, then you're probably running an Apache httpd from a prebuilt package, and need to get the Apache development package that goes with it.

For instance, on RedHat (or another Linux that supports RPMs), you would find your httpd version like so:

rpm -qa | grep httpd

If this showed httpd-2.0.44-1.8.0, then you would want to download httpd-devel-2.0.44.1.8.0.rpm (try http://rpmfind.net), and install it:

rpm -i httpd-devel-2.0.44.1.8.0.rpm

Note that many http-devel RPMs do not contain instdso.sh, the Apache extension installer. If locate instdso.sh does not turn up the installer, then you will need to get and upack the source for Apache. You do NOT need to build from source, just find instdso.sh in the [apache src]/build directory and copy it into /usr/lib/http/build .

Get IMAP

We need to build php with IMAP if we want FogBugz to receive email. If this is not a requirement for you, you can skip this part.

If you do need IMAP, try this to see if you can find the libc-client library: if you have it, then you can proceed on to building PHP.

locate libc-client.a

Again, you are only likely to be missing this if you did not originally build from source.

From the PHP manual entry on php-imap at http://php.net/manual/en/ref.imap.php:

This extension requires the c-client library to be installed. Grab the latest version from ftp://ftp.cac.washington.edu/imap/  and compile it.

It's important that you do not copy the IMAP source files directly into the system include directory as there may be conflicts. Instead, create a new directory inside the system include directory, such as /usr/local/imap-2000b/ (location and name depend on your setup and IMAP version), and inside this new directory create additional directories named lib/ and include/. From the c-client directory from your IMAP source tree, copy all the *.h files into include/ and all the *.c files into lib/. Additionally when you compiled IMAP, a file named c-client.a was created. Also put this in the lib/ directory but rename it as libc-client.a.

Did you get all of that? After downloading and building imap (let's assume you picked up imap-2004a) you need to:

mkdir /usr/local/imap-2004a

mkdir /usr/local/imap-2004a/include

mkdir /usr/local/imap-2004a/lib

cd c-client

cp *.h /usr/local/imap-2004a/include

cp c-client.a /usr/local/imap-2004a/lib/libc-client.a

Okay, now IMAP is ready, on to building PHP.

Build and install PHP

Now we're ready to build PHP with the extensions needed to run FogBugz.

cd to your [builddir]/php-4.3.10

./configure --with-apxs2=/usr/sbin/apxs --enable-xml --with-imap=/usr/local/imap-2004a --with-imap-ssl=/usr/include/openssl --with-mysql --with-iconv --with-zlib-dir=/usr/lib --disable-magic-quotes

Notes:

make
make install
rm ~/.pearrc

Now the new version of PHP should be installed on your system. If you're not sure Apache is using the correct version of libphp4.so, then you can use a test script to make sure.

Run the FogBugz install script

Change dir to your fogbugz directory and:
php -d output_buffering=0 -f install.php

This will make sure that the fogbugz .so is set to be loaded in php.ini and that your new PHP has access to all of the modules it needs via PEAR.

Test

Hit your FogBugz URL from your web browser. If everything looks right with FogBugz, then congratulations, you have upgraded. If not, then hit [your fogbugs url]/install1.php; this will automatically diagnose many problems and suggest solutions. Note that you do NOT need to complete these installation screens again. This is just a convenient way to allow the FogBugz installation to determine what might be wrong with your setup.