After php update, OCI8 module does not work or get missing ora_pconnect or ora_connect

I happen to use remi as the repository for some of our PHP programs.

 

After upgrading from remi php 7.0 to 7.1, I found us with these errors:

 

[In apache error log]

 

[24-Oct-2018 21:00:01 America/New_York] PHP Fatal error: Call to undefined function oci_connect() in /var/www/html/<some php program> on line “x”
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib64/php/modules/oci8.so’ – libclntsh.so.18.1: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib64/php/modules/pdo_oci.so’ – libclntsh.so.18.1: cannot open shared object file: No such file or directory in Unknown on line 0

 

#php -v

PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib64/php/modules/oci8.so’ – libclntsh.so.18.1: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib64/php/modules/pdo_oci.so’ – libclntsh.so.18.1: cannot open shared object file: No such file or directory in Unknown on line 0
PHP 7.1.23 (cli) (built: Oct 10 2018 12:11:12) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

 

Oh no… what happened? OCI8 no longer loads…. Look at the libclntsh.so.18.1 error… We are missing a library now…

 

Turns out you need the oracle-instantclient18.3-basic-18.3.0.0.0-1.x86_64.rpm [or similar] from the Oracle website. Download and install the rpm. Usually a simple “yum install oracle-instantclient18.3-basic-18.3.0.0.0-1.x86_64.rpm” does the trick [assuming your running this command from where your oracle-instantclient18.3-basic-18.3.0.0.0-1.x86_64.rpm file resides].

 

But after running “php -v”, it’s still not working… why?

 

Need to tell ld on your system which the libraries are for oracle. You do this by “vi /etc/ld.so.conf.d/oci8.conf”.

 

Change [or add] to the oci8.conf file:

/usr/lib/oracle/18.3/client64/lib

[note: you might have the older /usr/lib/oracle/12.1/client64/lib, so just change the 12.1 or 12.2 to 18.3]

 

Now tell ld to rebuild and check ldconfig:

 

# ldconfig

# ldconfig -v

<various info>

/usr/lib/oracle/18.3/client64/lib:
liboramysql18.so -> liboramysql18.so
libons.so -> libons.so
libocijdbc18.so -> libocijdbc18.so
libociei.so -> libociei.so
libocci.so.18.1 -> libocci.so.18.1
libnnz18.so -> libnnz18.so
libmql1.so -> libmql1.so
libipc1.so -> libipc1.so
libclntshcore.so.18.1 -> libclntshcore.so.18.1
libclntsh.so.18.1 -> libclntsh.so.18.1

<more various info>

 

Now, running a “php -v” results in:

 

# php -v
PHP 7.1.23 (cli) (built: Oct 10 2018 12:11:12) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

 

and/or restart apache to read the new ld config.