Php – Installing multiple php versions plus extensions on freebsd

freebsdPHP

I'm a currently learning how to work with freebsd. Lately I have been trying to run multiple php versions along with their respective packages. However, I seem to be running into issues while making installations.

The default location for my php installation is /usr/local/etc/, however I want to be able to install php5.2, php5.3 and php5.4 in /usr/local/etc/php52, /usr/local/etc/php53 and /usr/local/etc/php54 respectively.

Using ports I simply achieved this by doing cd /usr/ports/lang/php5x && make PREFIX="/usr/local/etc/php5x" install clean.

The problem now is: How do I do the same for extensions of all my PHP versions? When I try installing php-extensions like so: cd /usr/ports/lang/php5x-extension && make PREFIX="/usr/local/etc/php5x/lib/php" install clean, I get this error

...
===>  PHPizing for php53-bcmath-5.3.17
env: /usr/local/bin/phpize: No such file or directory
*** Error code 127

Stop in /usr/ports/math/php53-bcmath.
*** Error code 1

Stop in /usr/ports/lang/php53-extensions.

My PHPize is located in /usr/local/etc/php5x/bin/phpize
So how do I get make or whatever to look for phpize in the right path? Is there a cleaner, may be simpler way of maintaining multiple php installations? I need to achieve this because of compatibility issues from some legacy code that runs on 5.2 and breaks on 5.3.

Thank you.

Best Answer

The variable noone talked about is called PHPBASE: It allows working with multiple PHP installs on a FreeBSD server, placing each in it's own directory. It's then used in make.conf to point specific PHP modules (php52-somethings vs. php54-somethings) at the right "base" directory.

I've seen it used a few times, but didn't dare try it myself, so far.

When I looked for the an example for you I now actually found a apparently better example...

Look here:

http://webcodingstudio.com/blog/freebsd-92-server-configuration-apache-php-mysql-dns-samba

In case someone (still) wonders why one would do this:

The key is socalled seamless upgrades. It's something you do if you need to run servers for actual users and not just in your own basement. If you give users a quick path of upgrading and are able to switch forth/back between versions, they can eventually migrate. Otherwise they will eventually migrate too, not to the PHP version you give them, but to a different provider.