PHP versions like 5.2 and 5.3 have reached their “End of Life” status, yet many legacy applications and scripts still rely on them. If you need to run both an older PHP version (e.g., 5.3) alongside a newer version (e.g., 5.4 or 5.5) on your cPanel server, follow this step-by-step guide.
Step-by-Step Installation Guide
Assumption
We assume PHP 5.4 is installed as the default version on your server.
Step 1: Download and Extract PHP 5.3
Create a directory for building PHP 5.3, navigate to it, and download the required version:
mkdir /usr/local/buildphp53 cd /usr/local/buildphp53 wget http://museum.php.net/php5/php-5.3.9.tar.gz tar --strip-components=1 -zxvf php-5.3.*
Step 2: Configure and Install PHP
Run the configuration and make commands to install PHP 5.3:
./configure --prefix=/usr/local/php53 --enable-cgi --enable-bcmath --enable-calendar --with-mysql=/usr/bin --with-libdir=lib64 --with-gd --enable-mbstring make make install
Step 3: Add PHP 5.3 Handlers to Apache
Edit the Apache configuration file:
pico /usr/local/apache/conf/includes/pre_virtualhost_global.conf
Add the following lines:
Action application/x-httpd-php53 /cgi-sys/php53 AddType application/x-httpd-php53 .php53
Use Apache Distiller to apply these changes and prevent cPanel from scanning .htaccess
files for MIME types:
/usr/local/cpanel/bin/apache_conf_distiller --update touch /var/cpanel/easy_skip_update_php_mime_types
Step 4: Create the PHP 5.3 Handler
Create a file under the cgi-sys
directory and add the required script:
pico /usr/local/cpanel/cgi-sys/php53
Add the following:
#!/bin/sh exec /usr/local/php53/bin/php-cgi
Set the correct ownership and permissions:
chown root:wheel /usr/local/cpanel/cgi-sys/php53 chmod +x /usr/local/cpanel/cgi-sys/php53
Step 5: Copy PHP Configuration
Copy the php.ini
file from the PHP 5.3 build directory:
cp /usr/local/buildphp53/php.ini-production /usr/local/php53/lib/php.ini
Step 6: Create a Symlink for PHP 5.3 Executable
Create a symlink for PHP 5.3 to use it from the command line:
ln -s /usr/local/php53/bin/php-cgi /usr/local/bin/php53
Step 7: Restart Apache
Restart the Apache service to apply the changes:
service httpd restart
Step 8: Enable PHP 5.3 for Specific Accounts or Folders
To use PHP 5.3 for a specific folder, create a .htaccess
file inside the folder and add:
AddHandler application/x-httpd-php53 .php
Verify the installation by creating a phpinfo
file in the folder and checking if PHP 5.3 is active.
Important Notes
Compiling Modules:
Use the appropriate php-config
and phpize
files for PHP 5.3 modules.
phpize
: /usr/local/php53/bin/phpize
php-config
:
./configure --with-php-config=/usr/local/php53/bin/php-config
Security Concerns:
Running outdated PHP versions may expose your server to vulnerabilities. Limit their usage to specific cases and folders.
Backup Before Changes:
Always take a full server backup before making significant changes.
Need Assistance?
If you face any difficulties during the installation, our team at Host.co.in is here to provide 24/7 expert support.