I have a set of PHP-based websites hosted on a single Ubuntu 12.04 server that I need to upgrade PHP for. However, as some of the sites are QA / staging and others are production, I need to do this progressively. That is, I would like the QA sites to go first so I can check that upgrading PHP does not break anything, before rolling out to production. What's the best way to go about this?

The sites are all served through Apache and have their own vhost file.

I'm imagining that I can (somehow) install a new version of PHP at a specific point and through configuration (Apache? vhost?), specify that a site uses this version of PHP (rather than the one at /usr/bin/php).

The PHP versions in question are fairly old: I'm upgrading from PHP 5.3 to 5.4 at this point. Although (obviously) I need to get to 5.6 pretty soon. So I'm after a process that I can re-use.

  • In case there is, there is no easy way of doing that. I strongly suggest getting a different server, install the version of PHP you need and start migrating them one by one. – Dan Nov 26 '15 at 18:05

You should probably have two or more different servers, one for testing, the other for production, etc.. VPSs are really cheap now, and a VPS based solution would be way easier than this to configure, maintain, update, etc... The principle to keep in mind is called "KISS".

Anyway, back to the question: I would be looking into multiple FPM instances running on the same machine, one for each PHP version. This way it would be just a matter of one line of ProxyPassMatch to switch one site (i.e. vhost) from one PHP version to another. This would allow you to have a single Apache front-end with multiple PHP back-ends.

(Multiple Apache's on the same machine look like a nightmare to me).

Php-fpm is a separate CGI server that runs PHP outside of Apache. If you are still using mod-php, then you should first migrate to fpm and learn how to do proxying with Apache.

You would need to build each PHP version from source and install it to a different folder, prepare all the configuration, and create your init scripts. It's not too hard. You can find an example here (it's nginx based, but that's easy to migrate): http://www.sitepoint.com/run-multiple-versions-php-one-server/

If you do it, remember that you will need to keep PHP up to date with respect to security patches, so you will need to allocate time for downloading, recompiling and testing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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