SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    USA
    Posts
    1,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    two different PHP versions, two different user accounts, same machine?

    Here's a good article about setting up two different PHP version on the same machine at the same time.
    http://cms.227net.com/apache/run_php...5_concurrently

    Rather than have to append ":8080" to each URL you want to use, can you set up two different user accounts (windows xp pro) each with a different version of php with all else being equal?

    For example, I would add a user called, "PHP5 - MySQL5" which would have PHP version 5 and MySQL 5. Then set up another user account for PHP 4.3 and MySQL 4.1.

    I've figured out, with longneck's help, how to run two different verisons of MySQL at the same time but this new idea would help keep everything separate.

    Any thoughts or idea expansion is appreaciated!

  2. #2
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can have two separate apache.conf files, and then write a script which swap them, and restart the apache service.

  3. #3
    SitePoint Wizard dreamscape's Avatar
    Join Date
    Aug 2005
    Posts
    1,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can also run them on the same Apache on the same port at the same time, if you run at least one as a CGI. I do this, running PHP 4 as CGI and PHP 5 as an Apache DSO. It works fine for development, and saves on having to restart Apache any time you want to switch (I did that route for a bit, but really grew tired of it quickly, so went this route).

    I've got .php4 mapped to the PHP 4 CGI, and .php to the PHP 5 DSO by default. And I've also got the PHP 4 CGI setup so that I can change a directory or site to map .php to PHP 4 by simply using this in .htaccess (which I just comment/uncomment on sites I want to test in both PHP 4 and PHP 5):
    Code:
    AddType application/x-httpd-php4 .php

  4. #4
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is an interesting idea, isn't it? I mean not so much of the pairing of version 4 and 5 but more in regards to how it would work with version 5 and 6; Considering that it's said that version 6 of PHP will be available towards the years end...

    The WAMP I use at the moment gives me the option to run (easily) both version 4 and 5 but obviously I'm completely ignorant of version 4 now.

    Kyber...

    > You can have two separate apache.conf files, and then write a script which swap them, and restart
    > the apache service.

    Would you be willing to give more details and maybe an example?

  5. #5
    SitePoint Wizard Ren's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    1,060
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Running 2 versions of MySQL shouldn't be a problem, did it for awhile with 4 & 5.. just have to ensure they both have different service names. So can "net stop mysql5" "net start mysql4" etc.

    As for PHP, I use IIS (on a server os) so can have multiple websites, and therefore have independant .php mappings. Just stop one web service, and fire up another.

  6. #6
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dr Livingston
    > You can have two separate apache.conf files, and then write a script which swap them, and restart
    > the apache service.

    Would you be willing to give more details and maybe an example?
    That's how WAMP does it actually. I use that package too.
    Have a look at the file C:\wamp\scripts\switch.php.

  7. #7
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I can't find the specific file you refer to, but there are a few others. Didn't realise it was as simple as that though...

    Thanks.

  8. #8
    SitePoint Member jabba_29's Avatar
    Join Date
    Dec 2002
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Interesting comments, and glad you found the article helpful

    I actually have 3 instances of PHP running as I just upgraded the latest PHP 5 version. I have MySQL 3x and MySQL 4x running concurrently too - again over different ports, but this is just a simple change in the php.ini file for this one. Haven't upgraded to 5 yet, that seemed a bit tricky.

    Would be interesting to see if you could run apache if you could run Apache under different users, but it would never happen as you can't run 2 things through the same port - and I am pretty sure you have to specify the port for Apache when you use anything other than port 80.

    I thought about trying to set up subdomains running different PHP versions but I don't think this would be possible with PHP running both as modules.

    I, too, tried the CGI and module mix before, but I actually found this approach easier, though dreamscape's method is easy!

    I don't find it too much hassle to set the port number to the url, I only use this for testing at home anyways.

  9. #9
    SitePoint Member
    Join Date
    Mar 2006
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's a file in Windows 2K & XP at %WINDIR%\system32\drivers\etc\hosts (95, 98 & Me are bound to have one too, just don't know where).

    Amongst other things, it's used to map localhost to 127.0.0.1. Expanding on this, you can map several names to 127.0.0.1 and in your Apache config set-up several Virtual Hosts with different HostName's. This way you can run both on :80. Don't know if that's much better than :8080 though. Well, atleast it looks better! And the most fun is that you can use (almost) any hostname, like "___foo", "microsoft.com", etc. Fun if you want to confuse someone

    EDIT: Hmm, never thought about Apache preventing you from running multiple Virtual Hosts on :80... So I'm not actually sure if this will work, but I still think (/hope) it will. Guess I'll have to try it out later today.

  10. #10
    SitePoint Addict been's Avatar
    Join Date
    May 2002
    Location
    Gent, Belgium
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dr Livingston
    Well, I can't find the specific file you refer to,
    It's not standard in the wamp package, but in an add-on. After installing, you'll find the switch.php in the php4 subdirectory.
    Per
    Everything
    works on a PowerPoint slide

  11. #11
    SitePoint Member
    Join Date
    Aug 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I personally use two batch files (this one is php4to5.bat) :

    Code:
    net stop apache
    rename C:\httpd\php php-5.1.1
    rename C:\httpd\php-4.3.11 php
    rename "C:\Apache\conf\httpd.conf" httpd.conf.PHP5
    rename "C:\Apache\conf\httpd.conf.PHP4" httpd.conf
    net start apache
    With a shortcut in the QuickLaunch bar, changing from PHP4 to PHP5 is just one easy click, 0.1 second to change. What can be easier for a developement system ?

    Oh yes, naturally you need to build two php.ini files, one for each PHP version inside each directory, and set the PHPRC environment variable to point to C:\php so that the running version of PHP will always find its ini file.

  12. #12
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actualy it is possible to run both php4 and php5 at one time as modules.
    You just need to patch (manualy) several files.
    It works on my home PC and works perfect.
    Here is article how to patch it, but it's on Russian only. If anybody want to translate it - I can help.

  13. #13
    SitePoint Member
    Join Date
    Aug 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried your method except I used php 4.3.11 as normal setup and patched files for 5.1.2. Only the first module used after restarting Apache 1.3 works. i.e, if I run http://localhost:81/phpinfo.php to run PHP5, it works, and phpinfo says c:\php5\ph5.ini is used. However if I try to use PHP4 after PHP5, with http://localhost/phpinfo.php, I get not output, the browser freeze. If I restart Apache and run first http://localhost/phpinfo.php to use PHP4, it works, but then I can't use PHP5 after that.

  14. #14
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thierrybo
    I have no any problems with it.
    May be you don't patch everything you need? Or it's just configuring problem?

    Did you make add type in global server scope (wrong) or for needed virtual host only?
    addType application/x-httpd-ph5 .php

  15. #15
    SitePoint Member
    Join Date
    Aug 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I added it within a virtual host. It was what I understood from an online translation from russian to english, then english to french !

    Nut never mind, It was just a try!

  16. #16
    SitePoint Zealot Serberus's Avatar
    Join Date
    Oct 2005
    Location
    Herts, UK
    Posts
    113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I read that FastCGI lets you run 4 and 5 concurrently - I've yet to read up on the specifics yet though!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •