Forum Stats

  • 3,815,367 Users
  • 2,259,007 Discussions


Connecting to Oracle 19c from PHP

NuGlamSMS Member Posts: 74 Blue Ribbon
edited May 4, 2022 12:45PM in PHP

I have a Centos 8 server where I have installed PHP.

Then I installed OCI8 with this final result:


Libraries have been installed in:


If you ever happen to want to link against installed libraries

in a given directory, LIBDIR, you must either use libtool, and

specify the full pathname of the library, or use the '-LLIBDIR'

flag during linking and do at least one of the following:

  - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable

   during execution

  - add LIBDIR to the 'LD_RUN_PATH' environment variable

   during linking

  - use the '-Wl,-rpath -Wl,LIBDIR' linker flag

  - have your system administrator add LIBDIR to '/etc/'

See any operating system documentation about shared libraries for

more information, such as the ld(1) and manual pages.


Build complete.

Don't forget to run 'make test'.

running: make INSTALL_ROOT="/var/tmp/pear-build-rootwzbyph/install-oci8-2.2.0" install

Installing shared extensions:   /var/tmp/pear-build-rootwzbyph/install-oci8-2.2.0/usr/lib64/php/modules/

running: find "/var/tmp/pear-build-rootwzbyph/install-oci8-2.2.0" | xargs ls -dils

42049960  0 drwxr-xr-x 3 root root   17 Apr 26 18:40 /var/tmp/pear-build-rootwzbyph/install-oci8-2.2.0

20799814  0 drwxr-xr-x 3 root root   19 Apr 26 18:40 /var/tmp/pear-build-rootwzbyph/install-oci8-2.2.0/usr

25928868  0 drwxr-xr-x 3 root root   17 Apr 26 18:40 /var/tmp/pear-build-rootwzbyph/install-oci8-2.2.0/usr/lib64

33561584  0 drwxr-xr-x 3 root root   21 Apr 26 18:40 /var/tmp/pear-build-rootwzbyph/install-oci8-2.2.0/usr/lib64/php

42049964  0 drwxr-xr-x 2 root root   21 Apr 26 18:40 /var/tmp/pear-build-rootwzbyph/install-oci8-2.2.0/usr/lib64/php/modules

42049963 884 -rwxr-xr-x 1 root root 901808 Apr 26 18:40 /var/tmp/pear-build-rootwzbyph/install-oci8-2.2.0/usr/lib64/php/modules/

Build process completed successfully

Installing '/usr/lib64/php/modules/'

install ok: channel://

configuration option "php_ini" is not set to php.ini location

You should add "" to php.ini


I added the line to the php.ini file.

Now i don't get errors when trying to make a query, but it doesn't return any result.

I have query the phpinfo and I see OCI8 is correctly enable, but I don't see the PDO driver enabled for OCI.

Do I have to install PDO? I have read that OCI8 and PDO are two completely different PHP extensions designed to connect to Oracle databases

In case I have to install PDO, where can I find the instructions to follow for my server version?

This is my php version:

# php --version

PHP Warning: Module 'oci8' already loaded in Unknown on line 0

PHP 7.2.24 (cli) (built: Oct 22 2019 08:28:36) ( NTS )

Copyright (c) 1997-2018 The PHP Group

Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

Thank you in advance.



  • Roland Mueller
    Roland Mueller Member Posts: 79 Blue Ribbon

    Installing some web server related stuff under /var/tmp is not a good practice and it may be that in Redhat EL familily of Linux distributions (RHEL, CentOS, Oracle Linux, ...) you may encounter SELinux errors because of the installation directory.