Topic: OCI8 on Centos 8

Hello.

I need to install laravel with oracle database on my centos 8 server.

I have made it to install oracle 12c enterprise and laravel php framework.
In order to connect database to laravel I must install oci8 driver and later the yara library.

I need help with oci8 installation. I have alrady followed the wizard instrusctions:
https://rpms.remirepo.net/wizard/
but browsing to phpinfo() does not show that oci8 is enabled.

Could you please assist?

Thank you very much!

Re: OCI8 on Centos 8

You need the php-oci8 package and the Oracle Client Library version 19.6 (which allow to connect to Database 12)

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: OCI8 on Centos 8

Notice: Oracle provides RPM of the client library and everything will work out-of-the-box.

But, as you have 12c installed on the same machine, it is probably safer to NOT use the RPM, but rather a manual installation (as the RPM change the default linker path)

In this case, you will have to set the LD_LIBRARY_PATH so php can find the libclntsh.so.19.1 library

For web server, as C8 use FPM by default, you have to add this in the systemd unit file

Using "systemctl edit php-fpm" command, and adding the needed env

[Service]
Environment=LD_LIBRARY_PATH=/path/to/the/lib
Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: OCI8 on Centos 8

Hi Remi!

I messed up my system today and now I have formatted it once more. Now I have only oracle 12c enterprise installed without anything else.

I have also downloaded oracle-instantclient19.6-basic-19.6.0.0.0-1.x86_64 from oracle site without having yet installed it.

Could you please give me some directions?
I need to install php with oci8. Should I use your repository? And how shall I enable oci8?
Then I should proceed with instantclient19.6 installation via software center?

Thank you in advance.

Re: OCI8 on Centos 8

I need to install php with oci8. Should I use your repository? And how shall I enable oci8?

Of course, I think so.

For PHP and its extension, simply follow the Wizard instructions

Oracle instant client is a ZIP, you only have to unpack it somewhere and set LD_LIBRARY_PATH as explained previously

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: OCI8 on Centos 8

Hi Remi!

I haven't yet moved to oracle client installation, but so far I have followed wizard's instructions for Centos 8, php 7.4.6, single version.

At the point of installing additional packages, I ran the following:

# dnf install php-oci8
Last metadata expiration check: 0:04:16 ago on Sat 16 May 2020 10:05:11 PM EEST.
Dependencies resolved.
================================================================================
Package        Architecture Version                   Repository          Size
================================================================================
Installing:
php-oci8       x86_64       7.4.6-1.el8.remi          remi-modular       168 k
Installing dependencies:
php-pdo        x86_64       7.4.6-1.el8.remi          remi-modular       143 k

Transaction Summary
================================================================================
Install  2 Packages

Total download size: 311 k
Installed size: 998 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): php-oci8-7.4.6-1.el8.remi.x86_64.rpm     274 kB/s | 168 kB     00:00   
(2/2): php-pdo-7.4.6-1.el8.remi.x86_64.rpm      209 kB/s | 143 kB     00:00   
--------------------------------------------------------------------------------
Total                                           301 kB/s | 311 kB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1
  Installing       : php-pdo-7.4.6-1.el8.remi.x86_64                        1/2
  Installing       : php-oci8-7.4.6-1.el8.remi.x86_64                       2/2
  Running scriptlet: php-oci8-7.4.6-1.el8.remi.x86_64                       2/2
  Verifying        : php-oci8-7.4.6-1.el8.remi.x86_64                       1/2
  Verifying        : php-pdo-7.4.6-1.el8.remi.x86_64                        2/2

Installed:
  php-oci8-7.4.6-1.el8.remi.x86_64        php-pdo-7.4.6-1.el8.remi.x86_64       

Complete!


But when I tried to check php packages I got this message. I guess there is a problem with oci8. How can I fix it at this point?

Thank you a lot!

# php --modules
PHP Warning:  PHP Startup: Unable to load dynamic library 'oci8' (tried: /usr/lib64/php/modules/oci8 (/usr/lib64/php/modules/oci8: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/oci8.so (libclntsh.so.19.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 'pdo_oci' (tried: /usr/lib64/php/modules/pdo_oci (/usr/lib64/php/modules/pdo_oci: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/pdo_oci.so (libclntsh.so.19.1: cannot open shared object file: No such file or directory)) in Unknown on line 0
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mbstring
openssl
pcntl
pcre
PDO
pdo_sqlite
Phar
readline
Reflection
session
SimpleXML
sockets
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
xsl
zlib

[Zend Modules]

Re: OCI8 on Centos 8

As explained before, you need to set the linker path (LD_LIBRARY_PATH) to the directory where libclntsh.so.19.1 is installed.


For CLI, try

LD_LIBRARY_PATH=/oracle/installation!/path  php -m

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

8 (edited by konrms 2020-05-17 14:56:47)

Re: OCI8 on Centos 8

Hi Remi,

After installing oracle-instantclient19.6, the results of php --modules lists oci8 inside PHP Modules without warnings, so I guess there is no need to set the linker path.

I also successfully installed laravel and rechecked oci8 is active via phpinfo() function.

So everything works and I can proceed with my project.

Thank you very much for your support!



# php --modules
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mbstring
oci8
openssl
pcntl
pcre
PDO
PDO_OCI
pdo_sqlite
Phar
readline
Reflection
session
SimpleXML
sockets
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
xsl
zlib

[Zend Modules]

Re: OCI8 on Centos 8

> After installing oracle-instantclient19.6, the results of php --modules lists oci8 inside PHP Modules without warnings, so I guess there is no need to set the linker path.

Using the RPM provided by Oracle, this is expected (the linker path is set by a /etc/ld.so.conf.d/ file)

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: OCI8 on Centos 8

I have tried to summarize the various solution on
https://blog.remirepo.net/post/2020/05/ … ns-for-PHP

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: OCI8 on Centos 8

Very useful. Thank you a lot.

I have also created a guide on oracle 12c enterprise db installation on centos 8. It is a complex process but if anybody needs some help I can share my experience on that.