Installing two versions of php

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
chandrika
Forum Newbie
Posts: 10
Joined: Fri Feb 05, 2010 11:20 am

Installing two versions of php

Post by chandrika »

Hi, I have an old version 4.4.7 of php installed on my server, I have never upgraded it because I am not sure if the old scripts i have running on the server would continue to work properly, so to be sure I have left the old version installed.

I just was told that I can have two versions of php running on the server, so I am thinking of also having installed version PHP 5.3 but I am not sure how this works exactly, will all my old scripts keep working, will i simply be able to make use of the new functions etc available in the later versions and leave the old stuff running without a hitch, or are there some considerations i may not be aware of?

Thankyou
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: Installing two versions of php

Post by JakeJ »

Install it in another directory, change you Apapche (I'm assuming it's Apache) httpd.conf file to look in the new directory. Run your scripts and debug. You can always go back to the old version.

If the idea is to test your scripts on the new version, I would suggest installing it on a new machine. If you have a database, you might want to consider upgrading at the same time. Well, one piece at a time. But get both new components working together before upgrading the live site.
chandrika
Forum Newbie
Posts: 10
Joined: Fri Feb 05, 2010 11:20 am

Re: Installing two versions of php

Post by chandrika »

Thanks, yes it is Apache and from what you said it sounds as if I misunderstood what was told me elsewhere, that I could run both versions in tandem...as my problem is that I did not write most of the old scripts, I would have a hard job with my level pf experience debugiing them to work with a new version of PHP, plus there is quite alot of them.

So I had hoped and that is why I came here really to ask, if there was anyway that on my server I could have these old sites and their scripts pointing to and using one version of php, whilst also installing the new version there for any future sites I might do.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Installing two versions of php

Post by AbraCadaver »

chandrika wrote:Thanks, yes it is Apache and from what you said it sounds as if I misunderstood what was told me elsewhere, that I could run both versions in tandem...as my problem is that I did not write most of the old scripts, I would have a hard job with my level pf experience debugiing them to work with a new version of PHP, plus there is quite alot of them.

So I had hoped and that is why I came here really to ask, if there was anyway that on my server I could have these old sites and their scripts pointing to and using one version of php, whilst also installing the new version there for any future sites I might do.
You setup two separate vhosts in your apache httpd.conf each pointing to a different PHP executable running as CGI. Your original vhost would be port 80 and you could setup the second as port 81. So when you want to test the 5.3 version, just go to http://www.example.com:81
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
chandrika
Forum Newbie
Posts: 10
Joined: Fri Feb 05, 2010 11:20 am

Re: Installing two versions of php

Post by chandrika »

Thanks for these ideas, I have received another idea elsewhere that has said that I can install both versions, keep my current old version as the default version and then any time i wish to use the new 5.3 version, that all I have to do is if want to use/apply php5 for any account to simply create .htaccess file under respective cPanel account and insert rule AddHandler application/x-httpd-php5 .php in it.

That would sound the simplest solution for my needs (as it is only really for new accounts that I might be needing the later version (which i did not mention..sorry) but I always like to run such stuff by experts such as on a forum such as this for a second opinion, in case there is any downside to such...or in case i have received wrong info...otherwise that is probably what i will go ahead with as that way i can use both without too much difficulty on my part.

Thanks so much your help is much appreciated :)
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: Installing two versions of php

Post by JakeJ »

The main reason I suggested using two machines if possible is simply because it's easy for anyone, especially someone inexperienced to make mistakes in one thinking they're using the other. It wasn't so much a technical hurdle as a practical one.
Post Reply