Wednesday, June 20, 2012

PHP with ioncube loader CentOS

SkyHi @ Wednesday, June 20, 2012

Guide to upgrade PHP Linux. PHP 5.3.3 Red Hat, CentOS.
1. Remove currently installed PHP.
Without Plesk.
rpm -qa | grep php | xargs rpm -e --nodeps
With Plesk. This is required as the output of rpm -qa | grep php would also pass some Plesk packages to xargs rpm -e --nodeps and Plesk would be broken!
Using the grep -v psa will remove any output containing psa.
rpm -qa | grep php | grep -v psa | xargs rpm -e --nodeps
Personally I advise you check the output of.
rpm -qa | grep php
and,
rpm -qa | grep php | grep -v psa  
before piping to xargs.
2. Install PHP 5.3.3.
yum install php53* php53-*
3. Install the ioncube loader.
Download and extract the ioncube loader and install the ioncube loader module.
x86,
wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz && cd ioncube && cp ioncube_loader_lin_5.3.so /usr/lib/php/modules/
Now update the PHP config.
echo “zend_extension=/usr/lib/php/modules//ioncube_loader_lin_5.3.so” > /etc/php.d/ioncube-loader.ini
x86_64.
wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz && tar -zxf ioncube_loaders_lin_x86-64.tar.gz && cd ioncube && cp ioncube_loader_lin_5.3.so /usr/lib64/php/modules/
Now update the PHP config.
echo “zend_extension=/usr/lib64/php/modules//ioncube_loader_lin_5.3.so” > /etc/php.d/ioncube-loader.ini
4. Create dummy PHP package (Optional only required for Plesk  as it does not look for PHP53 packages only PHP.
Install rpmbuild.
yum install rpm-build
Create the php.spec.
nano -w php.spec
Include the following in the file.
Summary: Empty PHP required as Plesk doesent recognise the PHP53 packages.
Name: php
Version: 5
Release: 3.3
License: Public
Group: Applications/System
%description
Empty PHP RPM
%files
press ctrl+x to exit and save the file.
Now build the RPM.
rpmbuild -bb php.spec
This will then output a path to the created RPM.
Install the package
rpm -i /path/to/rpm
Exclude PHP from the main repos.
open the yum config.
nano -w /etc/yum.conf
add the following entry.
exclude=php
The exclude php is to prevent issues with php packages conflicting with php53. It wont stop php53 packages from updating.
5. Restart Apache
service httpd restart
Now check the version of PHP
php -v
Job done.



REFERENCES
http://box-admin.com/upgrade-php-linux/