The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP 4 AND PHP 5 on the same web server?

Discussion in 'General Discussion' started by Computer_Wizard, Nov 15, 2011.

  1. Computer_Wizard

    Joined:
    Oct 26, 2011
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Ok, before someone posts "Search the forums" I did do that, and from what I gather I know it is possible. I also saw a couple things on how to do it, but they were not very specific and I have a few questions about it. Essentially I need these answered because I don't have a server for our hosting that I can just take offline for a while to mess around with, and we would rather keep the down time limited instead of screwing around.

    Also, the reason I want to do this is that we have a number of users who have not updated their sites for some time, but still actively use them that require PHP 4. However many new members are unhappy we do not offer PHP 5, so I'm trying to make everyone happy (I know not technically possible, but you can't blame a guy for trying).

    BTW I am running cpanel 11.30

    as for what I need I would like to be able to run PHP 4 (doesn't really matter which exact version) and PHP 5 (most current version would be nice, but anything would be an upgrade really) on the same server. All old accounts would default to using PHP 4, and any new accounts created would use PHP 5, while allowing old accounts to upgrade if they wish.

    as for doing this, I saw one post suggest, after cpanel version 11, it is as easy as going to easyapache and specifying a major and minor version of PHP. Is it really that simple? Also, if I do that how long will the down time be while it rebuilds apache (approx) I can't imagine it would be long at all, but then again I haven't set this kind of thing up before so I figured I'd ask.

    If it is not that easy can anyone show me detailed instructions on how to do it? Like I said, I need to minimize downtime, so the more detailed the instructions the less surprises I'll have.
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    If you simply enable both PHP 4 and PHP 5 in WHM > EasyApache (Apache Update) or using /scripts/easyapache in command line, then PHP shouldn't be down at all during the recompile. I really suggest using WHM because at the end you'll have the option to select the default PHP version, and you'd want to pick PHP 4 as the default version.

    At that point, PHP 5 will be available but not the default. You'll need people to add the following to their .htaccess file to switch PHP 5 to their default if they prefer:

    Code:
    AddType application/x-httpd-php5 .php .phtml
    This would allow them to use .php files as PHP 5 in their own account.

    Otherwise, they can simply name the pages .php5 and they will use PHP 5 without the above line in .htaccess.
     
  3. Computer_Wizard

    Joined:
    Oct 26, 2011
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Ok, sorry to dig up an old thread, but I thought it better than posting a new one.

    With a few hiccups, a LONG discussion with cpanel support, and some headaches/cursing later, I was able to get this done and now have PHP4 and PHP5 on the same server.

    I was wondering though, is it possible to set all previous accounts to use PHP4, and then set the system default to PHP5 so that newly created accounts will use PHP5? This is essentially so that no older sites will break, but to start gradually pushing our users to use PHP5 (however both new and older users would be able to manually change it if desired).

    Thanks in advanced!
     
  4. NixTree

    NixTree Well-Known Member

    Joined:
    Aug 19, 2010
    Messages:
    386
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Gods Own Country
    cPanel Access Level:
    Root Administrator
    Hello,

    It is fairly easy to switch accounts to PHP4 on a PHP5 default server. Initially set PHP5 as default PHP version from WHM. For those accounts ( or domain ), which needs to use PHP4, put the following line into the htaccess file of its document root.

    AddHandler application/x-httpd-php4 .php .phtml

    If you remove this line from htaccess, it will start to use the defult PHP ( which is PHP5 )

    Thank you,
    Nibin.
     
  5. hicom

    hicom Well-Known Member

    Joined:
    May 23, 2003
    Messages:
    272
    Likes Received:
    0
    Trophy Points:
    16
    We've a server that is setup to run both PHP 4.4.9 and PHP 5.3.8. Both are setup as SUPHP.

    PHP 4 is setup as default.

    When using the code in .htaccess:
    Code:
    AddType application/x-httpd-php5 .php .phtml
    
    However, when calling the index.php file it pops up with a message asking to download the file index.php file to a computer (looks like it is not picking up the file as a script).

    is this because I have them both as suphp or something else?

    Thanks
     
  6. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Check /usr/local/apache/conf/php.conf file to see what it shows for PHP 5 there for the correct syntax. It might differ and that's why it isn't working.
     
  7. hicom

    hicom Well-Known Member

    Joined:
    May 23, 2003
    Messages:
    272
    Likes Received:
    0
    Trophy Points:
    16
    Thank you! It turns out after reviewing that file that PHP5 was setup as DSO instead of PHP. Corrected it, and all is working well now. Great reply!
     
Loading...

Share This Page