cPanel Config

Welcome to cPanelConfig the fastest growing cPanel configuration and troubleshooting guide on the internet. Please take the time and register. We would love to have your contribution to this completely free cPanel resource. We are updating this daily so be sure to visit us on a regular basis.

Running PHP 5 and PHP 4 on the same cpanel server

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5 out of 5)
Loading ... Loading ...

Posted by yolau

This article will help you install and run on the same server php 4 and 5. Users will be allowed to choose what version to use for their scrips.
Although I personally don’t recommend this as it has many performance implications it’s something that small webhosts use so that they don’t have to have different servers for different php versions.

O k, let’s get started. Before I explain how to install it please note that part of this article is inspired by a post on Defender Hosting Forum (http://forums.defenderhosting.com/showthread.php?t=2103)

  1. Compiler check
  2. /scripts/checkccompiler
    rm -rf /home/cpphpbuild
    mkdir /home/cpphpbuild
    cd /home/cpphpbuild

  3. Download and extract php
  4. wget http://us2.php.net/get/php-5.2.4.tar.gz/from/this/mirror
    tar zfx php-5.2.4.tar.gz
    cd php-5.2.4

  5. Configure and build the php installation (credits go to elix for an excellent work)
  6. echo “#define HAVE_SENDMAIL 1″ >> /home/cpphpbuild/php-5.2.4/main/php_config.h
    wget http://www.elix.us/tutorials/php5.gen.cpanel
    chmod 700 php5.gen.cpanel
    ./php5.gen.cpanel
    make
    make install

  7. Moving the files and finishing the configuration
  8. cp -f /usr/local/php5/bin/php5 /usr/local/cpanel/cgi-sys/php5
    chown root:wheel /usr/local/cpanel/cgi-sys/php5

    cp -p /home/cpphpbuild/php-5.2.4/php.ini-recommended /usr/local/php5/lib/php.ini
    chown root.root /usr/local/php5/lib/php.ini
    chmod 644 /usr/local/php5/lib/php.ini

    echo “cgi.fix_pathinfo = 1 ; needed for CGI/FastCGI mode” >> /usr/local/php5/lib/php.ini

  9. Now we have to add a few lines to the httpd.conf file
  10. pico /usr/local/apache/conf/httpd.conf

    Add in the section – “index.php5″ before index.php4
    Add after “AddType application/x-httpd-php .phtml”

    Action application/x-httpd-php5 “/cgi-sys/php5″
    AddHandler application/x-httpd-php5 .php5

  11. Test the installation
  12. service httpd configtest

    If you get any errors please check that you done all the steps properly.
    If everything is ok you can now restart apache

  13. Restart apache
  14. service httpd restart

Now any files with the extension .php5 will be parsed by php 5 and all the other files will be parsed by your “normal” php 4 installation.

Share this: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • del.icio.us
  • Slashdot
  • StumbleUpon
  • Netvouz
  • description
  • ThisNext
  • MisterWong
  • Wists
  • De.lirio.us
  • Furl
  • MyShare
  • Smarking
  • Technorati
  • YahooMyWeb

If you enjoyed this post, make sure you subscribe to my RSS feed!

One Response to “Running PHP 5 and PHP 4 on the same cpanel server”

  1. This is great if you have v4 and need v5.
    The new cpanel servers have v5 and I would like to add v4.

Leave a Reply