3

I work on a number of Joomla sites for clients, across multiple (differing) hosting environments. This can be a pain when troubleshooting as some of the hosts are running old versions of PHP (5.2) and some are on the latest.

Whenever I face an issue I like to download a copy of the website to my localhost environment (Apache/2.4.3 (Win32) PHP/5.4.7) and work from there. However in order to mirror the hosts environment I would need to change (downgrade) my PHP version also, right? How should I do this?

I am currently working on a Joomla (3.3.0) site now where the host is running PHP 5.3.28 (which has stopped receiving security updates since Thursday, 14 August 2014). I would like my local environment to mirror this for testing purposes (upgrading components, plugins etc..).

I have tried adding this line into my .htaccess however it doesn't seem to be changing anything. My Joomla > System Info > PHP Info still shows that I'm running PHP Version 5.4.7

AddHandler application/x-httpd-php5 .php

I've restarted Apache etc..

Perhaps I am doing something wrong, or if there is a more efficient way of doing what I would like I'd be open to suggestions.

My local Joomla websites are each in their own directory as follows

localhost/site1
localhost/site2
localhost/site3

2 Answers 2

2

The most efficient way in my opinion is to use something like MAMP, which has become available for Windows. The MAMP pro version gives you options to create as many hosts environments as you like and select different configuration on each one, including PHP versions.

It will save you from installing manually the PHP versions and setup the hosts environments you need for each project.

https://www.mamp.info/en/downloads/

2
  • Thanks @FFrewin I have never used MAMP and it looks like it will do exactly what I need. Is this process similar to creating virtual environments with say VirtualBox, only more simplified? I have an Ubuntu server with VirtualBox that I can create test environments in however it seems overkill for what I need.
    – jonboy
    Commented May 6, 2015 at 8:37
  • 1
    It is much simpler than creating VE in VB. Simply install the application follow the instructions to setup your first host, adjust settings to your needs and you are ready to go in 5 mins. I am using the MAMP pro in mac. I see the Win version is still in beta, but hopefully it should be working fine and any possible bugs would be addressed as you go. Definitely go for the commercial Pro version, as it allows you to create different hosts with different settings (even SSL) and choose among many PHP versions. Creating a new host it will be max 1 min thing.
    – FFrewin
    Commented May 6, 2015 at 8:42
3

Using FastCGI: in apache configuration:

FastCgiServer /var/www/cgi-bin/php-cgi-5.3.0
FastCgiServer /var/www/cgi-bin/php-cgi-5.4.0
FastCgiServer /var/www/cgi-bin/php-cgi-5.5.0

Create php-cgi-* files for each version in /var/www/cgi-bin/ e.g

/var/www/cgi-bin/php-cgi-5.3.0

which should point to right php

#!/bin/sh
PHPRC="/etc/php5/cgi/5.3.0/"
exec /path/to/php-cgi-5.3.0

Now apache directory configuration

<Directory "/var/www/sitename">
  AddHandler php-cgi .php
  Action php-cgi /var/www/cgi-bin/php-cgi-5.3.0
  ...
</Directory>

Repeat the steps for other versions.

Note: This process for linux environment but can be easily adapted to Windows.

1
  • Thanks @Nagarjun I will try this and get back to you, looks interesting - great if it works!
    – jonboy
    Commented May 6, 2015 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.