Play XAMPP "Happy Families" on Your PC

XAMPP (http://www.apachefriends.org/en/xampp-linux.html) is a great way of adding a LAMP stack to a Linux workstation for web design and development, coming as it does in packages covering a range of versions. However the XAMPP packages are designed to be installed in one specific location – /opt/lampp – making it next to impossible to use two or  more versions on one PC. However there is a way to get members of the XAMPP family to live happily together…

If you use the LAMP components (Apache, PHP, MySQL, etc.) that are available from the repository of your favourite Linux distribution you are tied to their current versions of these packages, and that is very possibly not the best choice suit your needs. XAMMP's big advantage is that it comes in a choice of versions (http://sourceforge.net/projects/xampp/files/XAMPP%20Linux/) which are matched packages of LAMP components ranging from the latest, through versions that are close to those found currently on commercial servers, to the those from the prehistory of the web a decade ago.

I find I need to have available at least two different versions of the LAMP stack:

  • a "mature" version for working on code from well-established web sites, and for new stuff that has to live on certain commercial servers whose administrators have a conservative approach to software updates.
  • a "not-quite bleeding edge" version for open source development work - the latest development versions of e.g. Joomla tend to need a really recent version of PHP as a basic requirement.

The problem is that each version of XAMPP requires exclusive use of the folder /opt/lampp in order to operate. There are just too many hard-wired folder locations scattered throughout the config. files and package code to consider patching these to suit a new location.

My own solution to this is to install the (currently 3) separate versions of XAMPP each in its own suitably-labelled folder. So I currently have a folder structure like this on my workstation:

/opt
/lampp_1.7
/lampp_1.7.7
/lampp_1.8.0
...other software folders in /opt

XAMPP will not operate directly in any of these folders – it is only happy if it thinks its sitting in /opt/lampp. So I create a soft link in /opt pointing to the folder containg my current choice of XAMPP version, rename it lampp, and run XAMPP and its utilities as if in /opt/lampp.

This works but there is a snag. To change from one version to another requires that the LAMP processes are first shut down (easily forgotten – with strange results when config. files etc. of a different version are put into place), the soft link erased and a new link created pointing to a freshly selected version of XAMPP.

This is rather tedious and I have once – in my haste – accidentally deleted a folder containing a version of XAMPP rather than the lampp link. Therefore I have put together a script that:

  • gives a choice of available versions of XAMPP (based on folder names containing them, based on the pattern shown above),
  • stops the XAMPP server processes,
  • deletes the existing lampp soft link,
  • creates a new soft link pointing at the folder containing the the chosen version of XAMPP.

This script is available for download here.