Upgrading a PHP 4 server to PHP 5

liunx

Guest
Hello Everyone, I am a web designer and I am trying to convince my job to upgrade their servers from php 4 to php 5. Mostly so I can make use of the better object oriented functionalities. This company has alot of websites on this server and they never tried to upgrade cause they are afraid that some websites that implement php 4 wont work with php 5.

My Question Is.
For a server that has alot of websites with php 4 on it. How big of a risk is it to upgrade to PHP 5 ???

Does anyone know any good sites that really take a close look on what changes were made and what to look out for when upgradingIs there some kind of way of installing php 5 on a php 4 server ?? like some kind of hack or something to safely do so ?? Like partition the hard drive or something. ??? What if Even the version of UNIX is old, is it possible to work php 5 on a older version of unix, or even up grade unix then upgrade php ???I work in a hosting company and I dont advise to upgrade from PHP 4 to PHP 5 if the server is serving a lot of websites. We were a little bit too optimistic and did just that couple of years ago and had to switch back very soon because there were so many sites that stopped working. We ofcourse now know most of the issues.. Mostly because register_globals and register_long_arrays configs(and maybe others that I dont recall now) but there were also some that required code changes.

The wisest way is to setup a new server with PHP 5 and move sites one by one to the new one and then tweak the config for the particular site if it doesnt work.

The latter question is harder to answer. We would need to know what unix flavour are you using and so on.. And if the whole operation system is old, even more so I suggest to just invest to a new server :)
Yes, it is possible to have PHP 4 and 5 at the same time but I havent tested it and someone wiser can comment on that.While you may work at a hosting company, the client should conform to the server, not the server to the client. Keep the server secure (register_globals disabled, magic_quotes_* off, etc) and then tell the people being hosted it's their responsibility to update their code. Especially since PHP 4 is past EOL.

We upgraded a server that houses a few hundred websites from php4 to php5, and it took maybe 2 hours to work out the kinks of the code for the clients.

You can install php4 and php5 concurrently; however, you'd have to run one as a CGI, and the other as a module. The downside is speed. The CGI will run slower typically.

The version of *nix does not matter, as php5 will run on it. I used to run php4 and php5 together on my windows machine for a while, just to see the differences while I was working on upgrading all my code to php5.

Your best bet is to do what was suggested and if you can, set up a server and move it over to there one at a time. If not, then I'd say you should get your company to let the customers know that they will be upgrading, and to work on fixing their code now as the upgrade will take place in like 2 weeks.What if we run php 4 and php 5 concurrently and slowly switch the sites over to php 5 from there. Because the company I work for is fairly small, and to get a new server would cost little over 700 dollars which they cant afford. So could it be safe to run php 4 and php 5 on the same server, switch the sites over to the new directories and slowly work the kinks out then after all said and done. get rid of the old directory. take php 4 off and switch the CGI version of php 5 over to moduleWell, it's possible. The only issue is deciding how they will be interpreted. If I were to do this, here's what I'd do:

(1) Set up a different "virtual host" listening on port 8080, use the same document root
(2) Override the default php settings in the virtual host to use the php5 cgi

Then test each site in php5, and make changes as needed, save the changes & files to a new folder (say: <sitename>_php5). Then once you've gone through all the testing and upgrading, just remove that virtual host, copy all files from <sitename>_php5 to the sites directory, then remove php4 and leave php5. It's a bit of an undertaking, but then you wouldn't really be impeding peoples views of the websites, and if you add something in php5 that isn't compatible with php4 (like using SimpleXML instead of DOM) you won't "break" the live site, you'll just have the changes for when you upgrade.

I hope that makes sense....
 
Back
Top