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.

How to Easy PHP4+PHP5 side by side (after removal of PHP4 from EasyApache)

Discussion in 'Workarounds and Optimization' started by asent, Nov 14, 2012.

  1. asent

    asent Active Member

    Joined:
    Apr 5, 2005
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    6
    Hey Everyone,

    Figured I would share how to have PHP4 and PHP5 running side by side after the removal of php4 from EasyApache. This is unofficial of course, follow my how to at your own risk.

    This how to will walk you through building PHP4 and PHP5 through EasyApache with PHP4 (*.php4) running as CGI and (*.php) PHP5 running as DSO.

    A little background... So I have been telling people for years to get over PHP4, I mean hell, PHP5 first released in 2004! At one point, I was running both versions simultaneously for my clients to have an option of what they wanted. I since migrated to a newer server and never built the PHP4 on the new box. Last week, I picked up a new client with a custom application for their company (no longer supported, developer out of business). Unfortunately, this custom application will not run on PHP5. I plan to eventually convert this application to work in this day and age as well as doing some customizations for them after. So I went ahead and moved this client over to my box so in the short term, I needed to rebuild PHP4 for this one client. Anyways long story short, I went through the steps of compiling PHP4 in EasyApache without disrupting my current 5.4 version. So with that being said, I know PHP5 has been out for nearly a decade and I also know PHP4 is no longer supported so no need for comments on that regard.

    As I previously said, PHP4 is no longer supported. I suggest you don't do this unless you absolutely need it. Since it's not supported anymore, it could leave your server more vulnerable than it would be without it.

    To install, please complete the following steps:

    1. Download the PHP 4 custom module for EasyApache

    Code:
    wget http://docs.cpanel.net/twiki/pub/EasyApache3/CustomMods/custom_opt_mod-PHP449.tar.gz
    2. Extract the tarball

    Code:
    tar -C /var/cpanel/easy/apache/custom_opt_mods -zxvf custom_opt_mod-PHP449.tar.gz
    3. Go to EasyApache and enable the PHP4.4.9 support module in the short options list.

    4. Build your EasyApache profile as you normally would (this will build apache, php4, and php5)

    5. After the build, you will have the php4 binary in your /usr/bin. Confirm it is working

    Code:
    php4 -v
    6. Also, verify your PHP5 is still working

    Code:
    php -v
    7. Configure apache to run both versions of php***

    Code:
    /usr/local/cpanel/bin/rebuild_phpconf 5 cgi dso 1
    ***NOTE: This works with my setup, your's may be different. Run rebuild_phpconf --current to see the current settings for your system. The syntax is rebuild_phpconf <Default PHP Major Version> <PHP4 Handler> <PHP5 Handler> <Suexec>. In my case, I set 5 as my default PHP version, cgi as my PHP4 handler, DSO as my PHP5 handler, and 1 (enabled) for suexec. Again, your configuration may be different.

    Now create two files in a webroot, phpinfo.php and phpinfo.php4 with the following contents:

    PHP:
    <?php
    phpinfo
    ();
    Ensure that your versions are correct. If there is a problem, you can always fall back by recompiling without PHP4 if something goes wrong, after setting your php4 handler to none of course.

    When you no longer need php4 support, you can and should run the following to disable it in apache then unchecking the module next time you build your EasyApache profile. (Again, this works for me. Do what works for you and your environment. See my note on rebuild_phpconf above)

    Code:
    /usr/local/cpanel/bin/rebuild_phpconf 5 none dso 1
    If your client's PHP4 script requires the extension to be .php instead of .php4, you can set the handler for the one site using a .htaccess file in the client's webroot with the following contents:

    Code:
    AddType application/x-httpd-php4 .php
    If you need to build a module for your PHP4 or modify the php.ini file, the PHP application files and configuration can be found at /usr/local/php4.

    Hope this helps someone who may find themselves in the same situation some day.
     
    #1 asent, Nov 14, 2012
    Last edited: Nov 14, 2012
Loading...

Share This Page