Category Archives: oracle

Upgrading PHP 5.3 to PHP 5.6 in CentOS 5.4

Due to some hardware restriction and limitations, i was forced recently to upgrade PHP from its previous version (5.3) to a slightly newer version (5.6). Below are the steps on how to do it with the least pain in the arse. At least in CentOS.

1. Upgrade to CentOS 5.11

Create a new repository file as below. If you don’t have it, just open a new file and create the content as such. Modify as necessary.

[base]
name=CentOS-$releasever - Base
baseurl=http://vault.centos.org/5.11/os/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

After adding/modifying the new repo file and set it to enabled, proceed to update to the latest version of CentOS 5 which is CentOS 5.11. It is not advisable or maybe impossible to upgrade to CentOS 6 from CentOS 5 without breaking or nuking the system.

yum update

Yeah, do your yummy thing, yum.

2. PHP 5.6 Installation

To install PHP 5.6, add these extra repositories:

rpm -Uvh http://archives.fedoraproject.org/pub/archive/epel/5/x86_64/epel-release-5-4.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

Before upgrading, do remove all traces of previous version of PHP:

yum remove php*
yum clean all

Now we can start installing PHP 5.6 by enabling REMI repo and disabling CentOS-Base repository.

CentOS-Base.repo

[base]
name=CentOS-$releasever - Base
baseurl=http://vault.centos.org/5.11/os/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

remi.repo

[remi]
name=Les RPM de remi pour Enterprise Linux 5 - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/5/remi/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/5/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
[remi-php56]
name=Les RPM de remi de PHP 5.6 pour Enterprise Linux 5 - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/5/php56/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/5/php56/mirror
# WARNING: If you enable this repository, you must also enable "remi"
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

After enabling the REMI repositories, we can start twith the installation of PHP 5.6 with modules selection of your choice:

yum install php-pear
yum install php-pecl-json
yum install php-fpm php-common
yum install php-opcache php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongo php-pecl-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml
yum install php

Somehow, i’m getting weird error if i’m installing PHP via yum first. Therefore i’m yumming php last. Once done. restart the Apache service:

service httpd restart

Just a sanity check, add this to make sure Apache starts on boot:

chkconfig httpd on

That should do it. PHP is now upgraded to version 5.6 🙂

3. Optional – OCI8 extension installation

To enable the OCI8 extension for Oracle, the Oracle InstantClient package is needed. Download the Oracle InstantClient from Oracle website, you may need to create an Oracle account. You will need to download the basic and devel package. Once downloaded, use rpm to install as such:

rpm -Uvh oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm
rpm -Uvh oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm

Take note of installation path of the InstantClient library files. In my case, its :

/usr/lib/oracle/11.2/client64/lib

If you are unable to find the InstantClient installation path, just use :

sudo updatedb
locate oracle | grep "client64/lib"

This will list all matching folders.

We can now proceed with the installation of OCI8 using PECL. PECL is installed together with PEAR. If you don’t have PEAR, there are good chance you don’t have PECL as well. Please install PEAR and PECL first if it’s not installed.

OCI8 extensions for PHP are grouped into 3 categories:

  • oci8 for PHP 7
  • oci8-2.0.12 for PHP 5.2 – PHP 5.6
  • oci8-1.4.10 for PHP 4.3.9 – PHP 5.1

Therefore, for PHP 5.6, i have to define the version as shown below. If it is not defined, the latest version will be installed and it will throw an error.

pecl install oci8-2.0.12

During the building process, you will be prompted for ORACLE_HOME location, just type the location in this format (<instantclient (do not change)>, <location of InstantClient library>:

instantclient, /usr/lib/oracle/11.2/client64/lib

If everything goes right, the OCI8 extension will be compiled and installed in your PHP extension directory (extension_dir) automatically. But you do need to to add this line in php.ini manually:

extension=oci8.so

Save the php.ini file, restart the Apache service and enjoy.

service httpd restart

Job well done. Adios.