Install php oci8 centos 8

In this tutorial I’ll show you how to 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.

I'm a system admin and php developer and currently working as System Admin In CWP Control panel, expertise in Linux and Windows administration RHEL certified admin.

I'm having a problem and very confuse at the moment.

I tried to install oracle instant client on my linux centos 8. What I achieved so far is httpd, php72 and mariadb is working fine. I can run my php file in the server.

I am following this tutorial to enable php oci8 in my LAMPP stack.

https://medium.com/@azharnian/cara-install-oci8-php-7-di-centos7-851abbb5d15

But stuck on this step which is

sudo pecl install oci8

Command prompt ask to provide the path to the ORACLE_HOME directory. Refer to the image.

Install php oci8 centos 8

I download and place my oracle-instant-client zip package in my /home/user/oracle

What I tried so far in this step is :

sudo sh -c "echo instantclient, /usr/lib64/php/modules"
sudo sh -c "echo instantclient_19_8, /usr/lib64/php/modules"
sudo sh -c "echo instantclient_19_8, /home/user/oracle/instantclient_19_8"
instantclient_19_8, /usr/lib64/php/modules/oci8.so
instantclient_19_8, /home/user/oracle/instantclient_19_8

Errors :

checking build system type... Invalid configuration `/usr/lib64/php/modules/oci8.so': machine `/usr/lib64/php/modules/oci8.so' not recognized

What exactly this step want me to write ?

Appreciate if someone can show me the right way on this. Many thanks.

How enable oci8 in PHP Linux?

Install Oracle Client Instant & SDK.
Download the latest Oracle Instant Client and SDK. Download the latest Oracle Instant Client and SDK from the Oracle website. ... .
Extract the files. ... .
Add in the ldconfig's config folder. ... .
Install packages. ... .
Install the OCI8 extension via PECL. ... .
Load extension from php.ini. ... .
Restart & check..

How configure oci8 in PHP?

The OCI8 extension can be added to an existing PHP installation by using the » PECL repository. When prompted, enter either the value of $ORACLE_HOME , or instantclient,/path/to/instant/client/lib . Make sure the php. ini directive extension_dir is set to the directory that oci8.so was installed in.

What is oci8 extension?

The OCI8 extension lets you access Oracle Database. Use 'pecl install oci8' to install for PHP 8.1. Use 'pecl install oci8-3.0. 1' to install for PHP 8.0.

How install oci8 on Windows?

1 Answer.
Download instantclient and place "C:\instantclient_11_2".
Set environment variable for C:\instantclient_11_2..
Check your php version i.e. PHP Version 5.6.15..
Un-Comment "extension=php_oci8_11g.dll" in php.ini and restart apache..
check php_info(), oci8 should be enabled. Thats all..