How to upgrade PHP version without any downtime?

Install each version of PHP to a different directory, switch between them using a symlink - in Unix, symlinks are atomic, meaning no downtime. Then simply restart your webserver to restart the worker threads thus using the new PHP version.

So:

/opt/php/5.1
/opt/php/5.2
/opt/php/live -> /opt/php/5.2

This isn't zero downtime, but its seconds downtime - per your requirement.


as Adam Gibbins and Zoredache have mentioned it is entirely dependent on your setup. If you use gentoo-linux for your server you can install each PHP version in different slots and then switch between them using eselect. You still have to restart the web-server, no getting around that but that's only seconds. Of course whatever method you use you'll need a test script to make sure everything is working AOK.