View Full Version : Installing both PHP4 & PHP 5 on Apache
chandrika
02-05-2010, 09:27 AM
I already have an old version of PHP running on server, which i have not upgraded as some scripts i have work on the old php version and i didnt want to mess them up.
But I read on another thread that some hosts have two versions of php running in tandem, so now i am thinking i can also install php version 5 and have both running on my server, so that my old scripts will keep running, but i can also make use of the later version of php.
Are there any problems associated with doing this, my main concern is that current scripts using version 4 go on working without a hitch.
chandrika
02-06-2010, 01:28 AM
I have been asking around for a solution to this, thought I would post what I found it here, for the record.
I have been told that I can get the both version of php installed on the server. Once they are done I can keep the old php version as default version of php on the server. And then if I want to use/apply php5 for any account i can simply create .htaccess file under respective cPanel account and insert rule AddHandler application/x-httpd-php5 .php in it.
So it sounds like it can be done without too much difficulty and all my old scripts can go on without a hitch.
So it sounds like it can be done without too much difficulty and all my old scripts can go on without a hitch.
Yes, if you are running your own dedicated server there should be no big problem installing and running both versions and you can gradually move the old files to the latest version. There are some compatibility problems with php 4 and php 5, so you should be careful and test thoroughly.
And be careful to install the latest stable version of php 5, namely
Current PHP 5.3 Stable: 5.3.1 (http://www.php.net/downloads.php#v5)
It should not differ much from the future php 6.0 version. I think the main remaining issues are unicode and language related. As I have understood, it takes time to implement these features.
Also note: PHP 6.0.0 (http://wiki.pooteeweet.org/PhP60)
This Pro PHP Refactoring with Test-Driven Design (http://www.apress.com/book/view/9781430227274) may be a useful book for a php professional.
williamc
02-07-2010, 08:19 AM
chandrika: we actually went the opposite route and made php 5 default, as we tend to update all of our scripts naturally anyways. For scripts that are not yet updated would would use AddHandler application/x-httpd-php4 .php in .htaccess
chandrika: we actually went the opposite route and made php 5 default, as we tend to update all of our scripts naturally anyways.
That is my preferred configuration too. Finally all my 4 hosters supply php 5.+
Another highly recommended book http://www.webproworld.com/programming/95633-professional-php-6-a.html#post483321 that also teaches you to set up a unit test environment for php (http://phpunit.sourceforge.net/)
Related link: Extreme Programming: A Gentle Introduction. (http://www.extremeprogramming.org/)
conortreacy
02-08-2010, 11:15 AM
We have a number of dedicated server users runing both the PHP4 and PHP5 on their boxes however we've been strongly urging users to move to the PHP5 platform as PHP4 is EOL and is out of PCI Compliance at this point. Last thing you'd want is not being able to process Credit Cards etc on the site.
PHP 5.3 is a big jump from the current 5.2.12 and is going to play havoc with a number of scripts (at least if used currently).
If you're still utilizing PHP4, I recommend researching what it will take to get your script into PHP5 as without those updates from a current program, PHP4 is a sitting duck for potential exploits.
Look here: <Code Deleted>
I am testing the code for the Professional PHP 6 Book there, and so long I have had no problem. Excellent American hoster. Impression: True professional service
The books foccus is on
PHP evet handlers.
Object overloading.
Pushing PHP to its limits
and much more.
chandrika
02-08-2010, 10:15 PM
Thanks, I have not had time to run any tests yet, but have installed version 5.2.11..the sites are still operating at least!
I installed that version purely on the recommendation of the admin where I rent the server, I did suggest 5.31 as on php.net that appeared to be the latest stable version, so I am not sure why they recommended that older version, maybe the leap being smaller as previously mentioned here...any ideas on that?
So it is a long haul debugging what scripts I have, but definitely will be preferable to get the default to be version 5 asap....and then the leap to version 6, thanks for the book tips there Kgun.
Thanks for all the useful info here.
On installations offered by the professonal hosters, you can:
specify which versions of PHP you would like to use for different directories by adding the following to your .htaccess files in those directories:
#PHP 5.2.11 /w Suhosin
AddHandler application/x-httpd-php52s .php
#PHP 5.2.12
AddHandler application/x-httpd-php52 .php
#PHP 6
AddHandler application/x-httpd-php6 .php
The best hosters now offer a PHP Switcher option in the cPanel under
Software / Services.
One of my four hosters offers
5.3.1 Default
5.2.11 Suhosin
5.2.12
6
I can change version by selecting a radio button and see the immediate effect on all sites hosted by that hoster. So if I have to fine tune the Switcher, I have to manully do it as explained above.
That is an argument for using a shared host or a managed server.
edhan
03-19-2010, 10:23 AM
I have my dedicated servers running on both PHP4 & PHP5 but default as PHP5. So far I have tested most of my sites, it appeared okay with PHP5. As I have more than 50 sites, I have yet to go through every one of them. So far none of my users or clients are complaining, so I guess it should be running fine.