Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

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

    Apr 5, 2005
    Likes Received:
    Trophy Points:
    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

    2. Extract the tarball

    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

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

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

    /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:

    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)

    /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:

    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

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice