You've opened a new tab!

Sound familiar? You know IE holds back the Internet right?

Here you'll be able to find my brief notes on computer/linux things I'm currently doing, and if I had any troubles, details about how they were overcome.

My public GPG key
My public SSH key

My github

My nicknames:

  • cgerpheide (official)
  • phoxicle (IRC, forums, twitter)
  • HorseRayX (AOL -- haven't used this one since I was 11)

A list of my favorite XKCDs:

C0mput3rz & T3chno1ogy

Installing PHP 5.2 and 5.3 together in Gentoo

PHP packages in Gentoo are marked with slots so that you can have major releases like PHP4 and PHP5 installed concurrently on your system. However, all packages within a major version use the same slot, so that when you upgrade from say, PHP 5.1 to 5.2, the 5.2 files will replace those from 5.1. Sometimes though we want to be able to even have medium or even minor releases both installed (in my case, I wanted PHP 5.3 for FLOW3, and PHP 5.2 for TYPO3). At the time of writing, PHP 5.3 is not in the portage tree yet (or actually any overlays), so now I face two problems: 1) find a working 5.3 ebuild and 2) install that ebuild alongside PHP 5.2.

Problem (1) was solved for me by downloading the 5.3.0 ebuild from the version bump request issue here. Put the ebuild files in /usr/local/portage/dev-lang/php/. There is also an ebuild for a slotted 5.3.1 attached to this issue -- which sounds even better -- but unfortunately it wasn't compiling for me.

So now that we have our ebuild, we need to install it together with 5.2. One approach would be to edit the ebuild, adding a new 5.3 slot and make sure no files are placed in generic php5 directories, which would then obviously conflict with other installations. But, I don't know enough about editing ebuilds to do that. So the gameplan becomes: move your current PHP files/folders out of the default locations, install PHP 5.3 normally, move around the PHP directories to your liking, and then figure out how to switch between the different versions. Ready? Go.

Explained in a bit more detail now... First step is move your current PHP installation (in my case 5.2) to a new location (or if you haven't installed PHP yet, install it now). Note, you may need to adjust your exact file locations, and I am assuming that the apache module is being used.

# mv /usr/lib/php5 /usr/lib/php5.2/
# mv /usr/lib/apache2/modules/ /usr/lib/apache2/modules/

Now that our current installation is safe, install PHP 5.3. You should see that you can now upgrade from your new ebuild.

# emerge -av php

After compiling, PHP 5.3 will be installed in /usr/lib/php5 and PHP 5.2 will still be where we put it earlier. In my case, I wanted to have PHP 5.2 installed in the default PHP5 locations, so that future upgrades from portage would replace that release. So at this point I moved around these directories so that 5.2 was in /usr/lib/php5, and 5.3 was in /usr/lib/php5.3. Do as you wish. What you SHOULD do, however, is copy the apache shared object:

# cp /usr/lib/apache2/modules/ /usr/lib/apache2/modules/

At this point we have two working PHP versions installed. If you start apache now, you should be able to use whichever object file is currently in So, now all we have to do is figure out how to switch between them. Switching involves setting and setting the PHP-relevant symlinks inside of /usr/bin/ to the correct PHP path. To do this I have created a short script called php-minor-select. With this, you should be easily able to switch between PHP 5.3 and 5.2 (or other medium/minor installations).

And that's it. I recognize that there are probably easier and better ways to accomplish this, like creating a real slotted 5.3.0 ebuild and perhaps configuring the existing php-select to switch between them, but this was the most straightforward thing for me to do personally. Anyway, hope this proves useful to someone else as well :). Now although I haven't done FULL testing, my web apps seem to run correctly in both environments, and who wouldn't be excited about that?