• Home
  • About Us
  • Contact
  • Privacy Policy

LinuxAdmin.io

  • Home
  • Tutorials
    • System Administration
    • Linux Tutorials
    • Web Hosting
    • WordPress
    • Virtualization
    • Troubleshooting
    • OpenStack

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:

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:

wget -O /usr/src/php-5.2.17.patch https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt

Then uncompress the php package:

tar xfvz php-5.2.17.tar.gz;

Navigate to the uncompressed directory:

cd php-5.2.17;

Apply the patch to the php install:

patch -p0 < ../php-5.2.17.patch;

Next go ahead and configure php,I used the following configure options:

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

make && make install

Create the needed files for cPanel

create /usr/local/cpanel/cgi-sys/php52 and add the following code:

#!/bin/sh
exec /opt/php52/bin/php-cgi

Save it and change the permissions:

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:

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

<?PHP
phpinfo();
?>

 

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

Apr 19, 2017LinuxAdmin.io
0 0 votes
Article Rating
Disable Wordpress Crontab and Run it ManuallyJournalctl Introduction and Examples
You Might Also Like
 
WebP Image Conversion On A Linux Server
 
ModSecurity Installation With Apache On CentOS
Subscribe
Notify of
guest

guest

4 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Patrick de Freitas
Patrick de Freitas
6 years ago

patch -p0 < ../php-5.2.17.patch; returned no such user

0
Reply
LinuxAdmin.io
Author
LinuxAdmin.io
6 years ago
Reply to  Patrick de Freitas

Hello,
Which directory are you in when executing that?

0
Reply
Lars
Lars
6 years ago
Reply to  LinuxAdmin.io

wget -O /usr/src/php-5.2.17.patch https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt

Do:

cd /usr/src/

Then continue with:

tar xfvz php-5.2.17.tar.gz;

So on and so forth. 🙂

0
Reply
LinuxAdmin.io
Author
LinuxAdmin.io
6 years ago
Reply to  Lars

I did have a cd /usr/src, there was just a missing space in the initial command. I corrected it, thanks!

0
Reply
8 years ago 4 Comments cPanel, PHP, Web Hosting 2,697
Recent Posts
  • Configuring Firewalld to Work Seamlessly with Docker on CentOS
  • Mastering NGINX Tuning: Optimizing Web Server Performance
  • Exploring eBPF: Revolutionizing Network and System Monitoring
  • Kubernetes: Installation and Overview on CentOS 8
  • Install Docker on Centos 8
Most Commented
Hot Clone Linux Server with Rsync
Hot Clone A CentOS Server With Rsync
14 Comments
ngx_cache_purge module
Install The ngx_cache_purge Module In Nginx
8 Comments
piwik-nginx
Piwik Analytics on Nginx
8 Comments
Tags
linuxcentosLinux Performance Tuningsysadminkvmnetworkingmemcachedanalyticssystemd
About

We love Linux and are dedicated to creating Linux administration tutorials for System Administrators since 2016.

Most Viewed
Default Gateway
How To Configure A Default Gateway on CentOS
76,147 views
Zend Opcache
Setup and Optimize Zend OpCache
47,105 views
Install ffmpeg
FFMpeg Install On CentOS 7
21,675 views
Archives
Email subscription

Sign up for our newsletter to receive the latest news and event postings.

2018 © LinuxAdmin.io
wpDiscuz