Jump to content

How to Install PHP OCI8 and Oracle InstantClient In CWP Centos stream 8 Centos 7


Recommended Posts

Install OCI8 php extension in CWP/Centos8/Centos7. This OCI8 extension lets you access Oracle Database.

These functions allow you to access Oracle Database. They support SQL and PL/SQL statements. Basic features include transaction control, binding of PHP variables to Oracle placeholders, and support for large object (LOB) types and collections. Oracle’s scalability features such as Database Resident Connection Pooling (DRCP) and result caching are also supported.

For el8/Centos 8/stream/Rocky/Almalinux :
First download the required Oracle instantclient packages :

cd /usr/local/src
wget https://download.oracle.com/otn_software/linux/instantclient/215000/oracle-instantclient-basic-21.5.0.0.0-1.el8.x86_64.rpm
wget https://download.oracle.com/otn_software/linux/instantclient/215000/oracle-instantclient-sqlplus-21.5.0.0.0-1.el8.x86_64.rpm
wget https://download.oracle.com/otn_software/linux/instantclient/215000/oracle-instantclient-devel-21.5.0.0.0-1.el8.x86_64.rpm
wget https://download.oracle.com/otn_software/linux/instantclient/215000/oracle-instantclient-jdbc-21.5.0.0.0-1.el8.x86_64.rpm


Second Installation :

cd /usr/local/src
dnf localinstall oracle* --nogpgcheck


For el7/Centos 7:
First download the required Oracle instantclient packages :

cd /usr/local/src
wget https://download.oracle.com/otn_software/linux/instantclient/215000/oracle-instantclient-basic-21.5.0.0.0-1.x86_64.rpm
wget https://download.oracle.com/otn_software/linux/instantclient/215000/oracle-instantclient-sqlplus-21.5.0.0.0-1.x86_64.rpm
wget https://download.oracle.com/otn_software/linux/instantclient/215000/oracle-instantclient-devel-21.5.0.0.0-1.x86_64.rpm
wget https://download.oracle.com/otn_software/linux/instantclient/215000/oracle-instantclient-jdbc-21.5.0.0.0-1.x86_64.rpm


Second Installation :

cd /usr/local/src
yum localinstall oracle* --nogpgcheck


Now install OCI8 php extension :
Now you need to install oci8 php extension via below process, please note the versions for oci8 are sensitive with the php version.

For php switcher :

php 7.x :

cd /usr/local/src
wget https://pecl.php.net/get/oci8-2.2.0.tgz
tar -zxvf oci8-2.2.0.tgz
cd oci8-2.2.0
phpize
./configure
make && make install


php 8.0 (only):

cd /usr/local/src
wget https://pecl.php.net/get/oci8-3.0.1.tgz
tar -zxvf oci8-3.0.1.tgz
cd oci8-3.0.1
phpize
./configure
make && make install


php 8.1 (only):

cd /usr/local/src
wget https://pecl.php.net/get/oci8-3.2.1.tgz
tar -zxvf oci8-3.2.1.tgz
cd oci8-3.2.1
phpize
./configure
make && make install


Now add this line at the end of this file /usr/local/php/php.ini :

extension=oci8.so
Now you can check the phpinfo there you can see oci8 is now enabled.

For php selector and php-fpm if you need to install oci8 for php 7.4 then replace phpize and ./configure with :

**change 74 to 80 for php 8.0 or to 81 for php 8.1

For php selector 7.4 :

/opt/alt/php74/usr/bin/phpize
./configure --with-php-config=/opt/alt/php74/usr/bin/php-conf


For php-fpm 7.4:

/opt/alt/php-fpm74/usr/bin/phpize
./configure --with-php-config=/opt/alt/php-fpm74/usr/bin/php-config


example :

cd /usr/local/src
wget https://pecl.php.net/get/oci8-2.2.0.tgz
tar -zxvf oci8-2.2.0.tgz
cd oci8-2.2.0
/opt/alt/php74/usr/bin/phpize
./configure --with-php-config=/opt/alt/php74/usr/bin/php-config
make && make install


and then add this line in php.ini :

extension=oci8.so


**restart php-fpm service or stop the php service and start it from cwp php-fpm module.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...