Announcement

Collapse
No announcement yet.

How to install PHP 5.2 IN CPANEL EASY APACHE 4

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to install PHP 5.2 IN CPANEL EASY APACHE 4

    PHP 5.2 in removed from cPanelís easy apache 4 for quite some time. However you can get it to run using a CGI handler. This isnít really recommended as newer versions of PHP offer both better performance and security when PHP 5.2 went end of life. That said, certain old code wont work without and if you are in a rush this will get you through it.

    First SSH into the server and sudo to root to get started.


    OBTAIN AND COMPILE PHP 5.2

    Then go to a install directory and get the last php 5.2 release:
    Code:
    cd/usr/src; wget http://museum.php.net/php5/php-5.2.17.tar.gz;

    Next get the patch for php-5.2.17 so it will compile on modern releases:
    Code:
    wget -O /usr/src/php-5.2.17.patch https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt

    Then uncompress the php package:
    Code:
    tar xfvz php-5.2.17.tar.gz;

    Navigate to the uncompressed directory:
    Code:
    cd php-5.2.17;

    Apply the patch to the php install:
    Code:
    patch -p0 < ../php-5.2.17.patch;

    Next go ahead and configure php,I used the following configure options:
    Code:
     ./configure  --prefix=/opt/php52  --enable-force-cgi-redirect  --enable-fastcgi  --with-regex=php  --enable-calendar  --enable-sysvsem  --enable-sysvshm  --enable-sysvmsg  --enable-bcmath  --enable-ctype  --with-iconv  --enable-exif  --enable-ftp  --with-gettext  --enable-mbstring  --with-pcre-regex  --enable-shmop  --enable-sockets  --enable-wddx  --with-libxml-dir=/usr  --with-zlib  --with-openssl  --enable-soap  --enable-zip  --with-gd  --with-mysql  --with-mysqli  --with-pdo-mysql  --with-pear  --with-jpeg-dir=/usr  --enable-gd-native-ttf  --with-ttf  --with-freetype-dir=/usr  --with-libdir=lib64

    then make and install php 5.2:
    Code:
    make && make install

    CREATE THE NEEDED FILES FOR CPANEL

    create /usr/local/cpanel/cgi-sys/php52 and add the following code:
    Code:
    #!/bin/sh
    exec /opt/php52/bin/php-cgi

    Save it and change the permissions:
    Code:
    chmod 755 /usr/local/cpanel/cgi-sys/php52

    Add to the following to the .htaccess of the domain you want to be in php 5.2:
    Code:
    AddHandler php-script .php
    Action php-script /cgi-sys/php52

    That will complete the setup. Finally make a test file in the document root to make sure it works
    Code:
    <?PHP phpinfo(); ?>

    This build will be independent of easy Apache and should persist through updates successfully.
Working...
X