I personally like to keep up to date with technologies and use the latest and greatest of whats available. Not everyone is the same though, and it is not always a possibility. In my case, using the latest version of PHP at the moment (PHP 5.3.0) means not being able to work with Drupal because the latest version of Drupal (v6.x) is built for PHP 5.2.6 and there exists some incompatibilities.
Like most people developing on a mac, I use MacPorts to install packages. I like how it easy and simple. Unfortunately, once a newer version of a package gets on the list, the older one disappears. But thanks to Joe Homs and Stephen Chu I now know of a way around this. In their posts they explain how to get older version of ruby, check their posts at:
http://www.stephenchu.com/2006/12/specifying-ruby-184-to-install-using.html
http://journal.bitshaker.com/articles/2007/10/20/install-old-versions-of-ports-using-macports/
I will go through the same steps but using PHP instead of ruby and I will be looking for PHP 5.2.10.
1) Find out the latest svn revision number of the Portfile before upgrading to 5.3.0 at:
http://trac.macports.org/log/trunk/dports/lang/php5/Portfile
In this case it is 53555.
2) Set up a local port repository. In the file /opt/local/etc/macports/sources.conf, add this line before the rsync line:
file:///Users/Shared/dports
and create that directory.
3) Install the port into your local repository.
cd /Users/Shared/dports
svn co http://svn.macports.org/repository/macports/trunk/dports/lang/php5/ -r 53555 lang/php5
4) Run portindex so that ports now finds your new (old) version of ruby.
portindex /Users/Shared/dports
5) Now you should be able to see php5 @5.2.10 by running:
port list
or port search php5
6) Install PHP5
sudo port install php5 @5.2.10
You should be up and running now, so to check, run:
php -v
If you already have another version of php activated you might get an error at the activation part of the port, deactivate the active version and manually activate the one you would like to work with:
sudo port deactivate php5 @5.3.0
sudo port -f activate php5 @5.2.10