This discussion is archived
5 Replies Latest reply: Apr 5, 2013 9:26 AM by cj RSS

Unable load  library '/usr/lib64/php/modules/oci8.so' - libclntsh.so.11.1

dariyoosh Journeyer
Currently Being Moderated
Dear all,


I have a problem with OCI8 installation and I would appreciate if you could kindly guide me how to solve this issue.

I started reading the following articles in order to learn how to install the OCI8 package allowing to connect from PHP to oracle

http://www.php.net/manual/en/oci8.installation.php

http://www.oracle.com/technetwork/articles/technote-php-instant-084410.html


Here is my environment description
OS: Fedora Core 17 (X86_64)
Oracle version: Oracle Enterprise Edition 11gR2 (11.2.0.1.0) X86_64
PHP Version: 5.4.13
Apache version: 2.2.23
Just a detail: almost every documentation starts by explaining the instant client installation. However, on the same physical machine, before even installing Apache and PHP. Oracle server had been completely installed, that is, both server and client (SQL*Plus, SQL*Loader, . . .). As a result, I omitted this step in the documentation and I continued by installation direcly OCI8 and apparently everything was compiled successfully (no error message).

Problem: OCI8 doesn't show up in phpinfo()

So it seems that there is a problem. I'm going to write down exactly how I proceeded and I would appreciate if you could kindly take a look at these steps and tell whether I made mistake(s)

I started by running as ROOT. As I said the oracle server was already installed on the machine and so all the required environment variables such as LD_LIBRARY_PATH, ORACLE_SID, . . . were already defined in ~/.bash_profile
And if you look at the below output, you can see that for example ORACLE_HOME was detected automatically during the installation (*checking Oracle ORACLE_HOME install directory... /u01/app/oracle/product/11.2.0/db_1*)
# pecl install oci8
This gave me the following output
# pecl install oci8
downloading oci8-1.4.9.tgz ...
Starting to download oci8-1.4.9.tgz (169,255 bytes)
.....................................done: 169,255 bytes
10 source files, building
running: phpize
Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525
Please provide the path to the ORACLE_HOME directory. Use 'instantclient,/path/to/instant/client/lib' if you're compiling with Oracle Instant Client [autodetect] : 
building in /var/tmp/pear-build-rootGiD7YE/oci8-1.4.9
running: /var/tmp/oci8/configure --with-oci8
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib
checking for PHP extension directory... /usr/lib64/php/modules
checking for PHP installed headers prefix... /usr/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for Oracle Database OCI8 support... yes, shared
checking PHP version... 5.4.13, ok
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking size of long int... 8
checking checking if we're on a 64-bit platform... yes
checking Oracle ORACLE_HOME install directory... /u01/app/oracle/product/11.2.0/db_1
checking ORACLE_HOME library validity... lib
checking Oracle library version compatibility... 11.1
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking for gawk... (cached) gawk
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for sysroot... no
checking for mt... no
checking if : is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC -DPIC
checking if cc PIC flag -fPIC -DPIC works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
configure: creating ./config.status
config.status: creating config.h
config.status: executing libtool commands
running: make
/bin/sh /var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/libtool --mode=compile cc  -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/include -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/u01/app/oracle/product/11.2.0/db_1/rdbms/public -I/u01/app/oracle/product/11.2.0/db_1/rdbms/demo  -DHAVE_CONFIG_H  -g -O2   -c /var/tmp/oci8/oci8.c -o oci8.lo
libtool: compile:  cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/include -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/u01/app/oracle/product/11.2.0/db_1/rdbms/public -I/u01/app/oracle/product/11.2.0/db_1/rdbms/demo -DHAVE_CONFIG_H -g -O2 -c /var/tmp/oci8/oci8.c  -fPIC -DPIC -o .libs/oci8.o
/bin/sh /var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/libtool --mode=compile cc  -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/include -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/u01/app/oracle/product/11.2.0/db_1/rdbms/public -I/u01/app/oracle/product/11.2.0/db_1/rdbms/demo  -DHAVE_CONFIG_H  -g -O2   -c /var/tmp/oci8/oci8_lob.c -o oci8_lob.lo
libtool: compile:  cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/include -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/u01/app/oracle/product/11.2.0/db_1/rdbms/public -I/u01/app/oracle/product/11.2.0/db_1/rdbms/demo -DHAVE_CONFIG_H -g -O2 -c /var/tmp/oci8/oci8_lob.c  -fPIC -DPIC -o .libs/oci8_lob.o
/bin/sh /var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/libtool --mode=compile cc  -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/include -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/u01/app/oracle/product/11.2.0/db_1/rdbms/public -I/u01/app/oracle/product/11.2.0/db_1/rdbms/demo  -DHAVE_CONFIG_H  -g -O2   -c /var/tmp/oci8/oci8_statement.c -o oci8_statement.lo
libtool: compile:  cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/include -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/u01/app/oracle/product/11.2.0/db_1/rdbms/public -I/u01/app/oracle/product/11.2.0/db_1/rdbms/demo -DHAVE_CONFIG_H -g -O2 -c /var/tmp/oci8/oci8_statement.c  -fPIC -DPIC -o .libs/oci8_statement.o
/bin/sh /var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/libtool --mode=compile cc  -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/include -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/u01/app/oracle/product/11.2.0/db_1/rdbms/public -I/u01/app/oracle/product/11.2.0/db_1/rdbms/demo  -DHAVE_CONFIG_H  -g -O2   -c /var/tmp/oci8/oci8_collection.c -o oci8_collection.lo
libtool: compile:  cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/include -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/u01/app/oracle/product/11.2.0/db_1/rdbms/public -I/u01/app/oracle/product/11.2.0/db_1/rdbms/demo -DHAVE_CONFIG_H -g -O2 -c /var/tmp/oci8/oci8_collection.c  -fPIC -DPIC -o .libs/oci8_collection.o
/bin/sh /var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/libtool --mode=compile cc  -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/include -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/u01/app/oracle/product/11.2.0/db_1/rdbms/public -I/u01/app/oracle/product/11.2.0/db_1/rdbms/demo  -DHAVE_CONFIG_H  -g -O2   -c /var/tmp/oci8/oci8_interface.c -o oci8_interface.lo
libtool: compile:  cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/include -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/u01/app/oracle/product/11.2.0/db_1/rdbms/public -I/u01/app/oracle/product/11.2.0/db_1/rdbms/demo -DHAVE_CONFIG_H -g -O2 -c /var/tmp/oci8/oci8_interface.c  -fPIC -DPIC -o .libs/oci8_interface.o
/bin/sh /var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/libtool --mode=link cc -DPHP_ATOM_INC -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/include -I/var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/u01/app/oracle/product/11.2.0/db_1/rdbms/public -I/u01/app/oracle/product/11.2.0/db_1/rdbms/demo  -DHAVE_CONFIG_H  -g -O2   -o oci8.la -export-dynamic -avoid-version -prefer-pic -module -rpath /var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/modules  oci8.lo oci8_lob.lo oci8_statement.lo oci8_collection.lo oci8_interface.lo -Wl,-rpath,/u01/app/oracle/product/11.2.0/db_1/lib -L/u01/app/oracle/product/11.2.0/db_1/lib -lclntsh
libtool: link: cc -shared  -fPIC -DPIC  .libs/oci8.o .libs/oci8_lob.o .libs/oci8_statement.o .libs/oci8_collection.o .libs/oci8_interface.o   -L/u01/app/oracle/product/11.2.0/db_1/lib -lclntsh  -O2 -Wl,-rpath -Wl,/u01/app/oracle/product/11.2.0/db_1/lib   -Wl,-soname -Wl,oci8.so -o .libs/oci8.so
libtool: link: ( cd ".libs" && rm -f "oci8.la" && ln -s "../oci8.la" "oci8.la" )
/bin/sh /var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/libtool --mode=install cp ./oci8.la /var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/modules
libtool: install: cp ./.libs/oci8.so /var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/modules/oci8.so
libtool: install: cp ./.libs/oci8.lai /var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/modules/oci8.la
libtool: finish: PATH="/usr/bin:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/.local/bin:/root/bin:/usr/local/jdk1.7.0_05/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/u01/app/oracle/product/11.2.0/db_1/bin:/opt/libreoffice4.0/program:/root/.local/bin:/root/bin:/usr/local/jdk1.7.0_05/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/u01/app/oracle/product/11.2.0/db_1/bin:/opt/libreoffice4.0/program:/root/.local/bin:/root/bin:/usr/local/jdk1.7.0_05/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/u01/app/oracle/product/11.2.0/db_1/bin:/opt/libreoffice4.0/program:/root/.local/bin:/root/bin:/usr/local/jdk1.7.0_05/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/u01/app/oracle/product/11.2.0/db_1/bin:/opt/libreoffice4.0/program:/root/.local/bin:/root/bin:/usr/local/jdk1.7.0_05/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/u01/app/oracle/product/11.2.0/db_1/bin:/op
t/libreoffice4.0/program:/root/.local/bin:/root/bin:/usr/local/jdk1.7.0_05/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/u01/app/oracle/product/11.2.0/db_1/bin:/opt/libreoffice4.0/program:/sbin" ldconfig -n /var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /var/tmp/pear-build-rootGiD7YE/oci8-1.4.9/modules

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/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

running: make INSTALL_ROOT="/var/tmp/pear-build-rootGiD7YE/install-oci8-1.4.9" install
Installing shared extensions:     /var/tmp/pear-build-rootGiD7YE/install-oci8-1.4.9/usr/lib64/php/modules/
running: find "/var/tmp/pear-build-rootGiD7YE/install-oci8-1.4.9" | xargs ls -dils
3679979   4 drwxr-xr-x. 3 root root   4096 Apr  4 15:48 /var/tmp/pear-build-rootGiD7YE/install-oci8-1.4.9
3680009   4 drwxr-xr-x. 3 root root   4096 Apr  4 15:48 /var/tmp/pear-build-rootGiD7YE/install-oci8-1.4.9/usr
3680010   4 drwxr-xr-x. 3 root root   4096 Apr  4 15:48 /var/tmp/pear-build-rootGiD7YE/install-oci8-1.4.9/usr/lib64
3680011   4 drwxr-xr-x. 3 root root   4096 Apr  4 15:48 /var/tmp/pear-build-rootGiD7YE/install-oci8-1.4.9/usr/lib64/php
3680012   4 drwxr-xr-x. 2 root root   4096 Apr  4 15:48 /var/tmp/pear-build-rootGiD7YE/install-oci8-1.4.9/usr/lib64/php/modules
3680008 596 -rwxr-xr-x. 1 root root 606865 Apr  4 15:48 /var/tmp/pear-build-rootGiD7YE/install-oci8-1.4.9/usr/lib64/php/modules/oci8.so

Build process completed successfully
Installing '/usr/lib64/php/modules/oci8.so'
install ok: channel://pecl.php.net/oci8-1.4.9
configuration option "php_ini" is not set to php.ini location
You should add "extension=oci8.so" to php.ini
# 
Once OCI8 was installed I updated the */etc/php.ini* accordingly by adding the following entries
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; If you wish to have an extension loaded automatically, use the following
; syntax:
;
;   extension=modulename.extension
                       .
                       .
                       .
extension=oci8.so
                       .
                       .
                       .
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; UNIX: "/path1:/path2"
;
;
                       .
                       .
                       .
extension_dir="/usr/lib64/php/modules"
Also I updated the */etc/sysconfig/httpd* in order to export the specified set of OS environment variables. So I added the following lines at the end of the file
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/db_1/lib:/u01/app/oracle/product/11.2.0/db_1/network/lib
LD_LIBRARY_PATH64=/u01/app/oracle/product/11.2.0/db_1/lib:/u01/app/oracle/product/11.2.0/db_1/network/lib
TNS_ADMIN=/u01/app/oracle/product/11.2.0/db_1/network/admin
NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252
ORACLE_SID=db01
In order to check that these values are actually taken into account by Apache, I run
# service httpd restart
Then I run a PHP script with phpinfo() and in the section Environment the above values were present in particular the LD_LIBRARY_PATH variable.

However, as I said, there is no OCI8 entry in phpinfo() output. I checked the apache log file and I saw that there is a problem
# cat /var/log/httpd/error_log
[Thu Apr 04 16:02:13 2013] [notice] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Thu Apr 04 16:02:13 2013] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Thu Apr 04 16:02:13 2013] [notice] Digest: generating secret for digest authentication ...
[Thu Apr 04 16:02:13 2013] [notice] Digest: done
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/oci8.so' - libclntsh.so.11.1: cannot open shared object file: No such file or directory in Unknown on line 0
[Thu Apr 04 16:02:13 2013] [warn] mod_wsgi: Compiled for Python/2.7.2.
[Thu Apr 04 16:02:13 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Thu Apr 04 16:02:13 2013] [notice] Apache/2.2.23 (Unix) DAV/2 PHP/5.4.13 mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
#
What I understand from the above log is that the shared library libclntsh.so.11.1 cannot be found. Yet I checked and I saw that it is present in LD_LIBRARY_PATH
# locate libclntsh.so
/u01/app/oracle/product/11.2.0/db_1/inventory/Scripts/ext/lib/libclntsh.so.11.1
/u01/app/oracle/product/11.2.0/db_1/inventory/backup/2012-06-25_12-08-41PM/Scripts/ext/lib/libclntsh.so.11.1
/u01/app/oracle/product/11.2.0/db_1/lib/libclntsh.so
/u01/app/oracle/product/11.2.0/db_1/lib/libclntsh.so.10.1
/u01/app/oracle/product/11.2.0/db_1/lib/libclntsh.so.11.1
# 
So the last line, shows that the specified library exists in */u01/app/oracle/product/11.2.0/db_1/lib/libclntsh.so.11.1*.

So I don't really seem what is the problem and the more strange thing is that in command line PHP seem to detect my oracle server parameters.
$ php --ri oci8

oci8

OCI8 Support => enabled
Version => 1.4.9
Revision => $Id: e2241cffb72c940cb2ca267b7a6a0ce436de7e5e $
Active Persistent Connections => 0
Active Connections => 0
Oracle Run-time Client Library Version => 11.2.0.1.0
Oracle Version => 11.2
Compile-time ORACLE_HOME => /u01/app/oracle/product/11.2.0/db_1
Libraries Used => -Wl,-rpath,/u01/app/oracle/product/11.2.0/db_1/lib -L/u01/app/oracle/product/11.2.0/db_1/lib  -lclntsh
Temporary Lob support => enabled
Collections support => enabled

Directive => Local Value => Master Value
oci8.max_persistent => -1 => -1
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
oci8.default_prefetch => 100 => 100
oci8.old_oci_close_semantics => Off => Off
oci8.connection_class => no value => no value
oci8.events => Off => Off
$ 
I thought maybe there are several different php.ini and the one used within GUI is not the same used in CLI but a search showed that there is just one php.ini file
# locate php.ini
/etc/php.ini
#
#
# php -i | grep Configuration
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini
Configuration
#
It is almost 3 days that I'm googling without success to find the solution to this problem.

So, could someone help me, what is the problem? Why the OCI8 module cannot be loaded by PHP and become visible in the phpinfo() output?


Thanks in advance,

Regards,
Dariyoosh
  • 1. Re: Unable load  library '/usr/lib64/php/modules/oci8.so' - libclntsh.so.11.1
    cj Employee ACE
    Currently Being Moderated
    Thanks for the detailed description.

    In /etc/sysconfig/httpd, use "export" on the variables. See various examples such as in "Setting the Oracle Environment for PHP on Linux" on p 77 of http://www.oracle.com/technetwork/topics/php/underground-php-oracle-manual-098250.html

    You are correct that PHP can install fine using an ORACLE_HOME.
  • 2. Re: Unable load  library '/usr/lib64/php/modules/oci8.so' - libclntsh.so.11.1
    dariyoosh Journeyer
    Currently Being Moderated
    >
    In /etc/sysconfig/httpd, use "export" on the variables. See various examples such as in "Setting the Oracle
    Environment for PHP on Linux" on p 77 of http://www.oracle.com/technetwork/topics/php/underground-php-oracle-manual-098250.html
    >


    Hello there,

    Thank you very much for your attention to my problem. The book is very interesting and informative (much better than the online documentation). I proceeded as you said and according to the examples in the book, that is, I used export in a single line in /etc/sysconfig/httpd in order to export the corresponding environment variables
        
    .
    .
    .
    export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:$ORACLE_HOME/network/lib
    export LD_LIBRARY_PATH64=$LD_LIBRARY_PATH64:$LD_LIBRARY_PATH
    export TNS_ADMIN=$ORACLE_HOME/network/admin
    export NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252
    export ORACLE_SID=db01
    Yet the problem persists. Also something strange happens when I run service httpd restart. The name of the variable for example LD_LIBRARY_PATH becomes export LD_LIBRARY_PATH, that is, the added export keyword becomes part of the variable name! In addition the value of the variables is not expanded, for example if the value of
    TNS_ADMIN=$ORACLE_HOME/network/admin
    instead of expanding ORACLE_HOME after the server restart and see
    /u01/app/oracle/product/11.2.0/db_1/network/admin
    I see the non expanded value in phpinfo() page, exactly as it was specified in /etc/sysconfig/httpd
    $ORACLE_HOME/network/admin
    I wonder whether there is a problem with apache. One more strange thing is that in the book that you provided the link, I see in many examples that the author uses */etc/init.d/httpd* executable to run the server. I don't have this on my installation. Is this normal?

    There is also something that attracted my attention after reading the page 92 in the book. The author uses
    apachectl start in order to run the server (instead of service httpd restart because according to the book this clears the environment and the set values are not therefore passed to apache)

    So instead of putting the variables inside */etc/sysconfig/httpd* I put them in an executable bash script which I created based on the book example.
    #!/usr/bin/bash
    
    export ORACLE_BASE=/u01/app/oracle
    export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/network/lib
    export LD_LIBRARY_PATH64=$ORACLE_HOME/lib:$ORACLE_HOME/network/lib
    export TNS_ADMIN=$ORACLE_HOME/network/admin
    export NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252
    export ORACLE_SID=db01
    
    # run apache based on the above environment variables
    apachectl start
    This time all values (including LD_LIBRARY) were expanded and printed correctly in the phpinfo() page.
    However I noticed that once you use directly apachectl, you cannot do service httpd restart any more and in order to be able to use that as before, the following two commands must be run (according to http://forums.fedoraforum.org/showthread.php?t=280875)
    # systemctl enable httpd.service
    # systemctl start httpd.service
    However, still there is no OCI8 entry in phpinfo() and the very same message error still appears in the log file
    # cat /var/log/httpd/error_log
    [Fri Apr 05 00:03:59 2013] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0
    [Fri Apr 05 00:03:59 2013] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
    [Fri Apr 05 00:03:59 2013] [notice] Digest: generating secret for digest authentication ...
    [Fri Apr 05 00:03:59 2013] [notice] Digest: done
    PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/oci8.so' - libclntsh.so.11.1: cannot open shared object file: No such file or directory in Unknown on line 0
    [Fri Apr 05 00:03:59 2013] [warn] mod_wsgi: Compiled for Python/2.7.2.
    [Fri Apr 05 00:03:59 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
    [Fri Apr 05 00:03:59 2013] [notice] Apache/2.2.23 (Unix) DAV/2 PHP/5.4.13 mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
    #
    Regards,
    Dariyoosh
  • 3. Re: Unable load  library '/usr/lib64/php/modules/oci8.so' - libclntsh.so.11.1
    cj Employee ACE
    Currently Being Moderated
    Since you say command line PHP is OK, I'm sure the problem is with setting the environment variables for Apache.
    The last time I saw a similar problem it was because I forgot to use 'export'. This was on Oracle Linux, which is equivalent to RHEL.

    I can't explain a couple of your most recent findings, e.g. what you are seeing when you use "export" in /etc/sysconfig/httpd.

    Try disabling SELinux. On Oracle Linux you would edit /etc/selinux/config, set SELINUX to DISABLED, and reboot. Also see the setenforce command.

    Regarding starting Apache, you would use apachectl start or /etc/init.d/httpd only if you have set environment variables in your terminal shell and you want those to pass down to Apache. If you look at the /sbin/service shell script (on Oracle Linux) you can see it runs "env -i" to start with an empty environment. So any environment values you set in the terminal shell would be ignored. This is why they need to be added to /etc/sysconfig/httpd when you use 'service'.

    Oh, and don't forget to give permissions to the Apache process owner to read the Oracle libraries and other data files in /u01/app/oracle/product/11.2.0/db_1. After a fresh DB install I always have to change the permissions on the ~oracle directory from 700 to 755. See "Commonly Seen Connection and Environment Errors" on
    page 107 of the book.
  • 4. Re: Unable load  library '/usr/lib64/php/modules/oci8.so' - libclntsh.so.11.1
    dariyoosh Journeyer
    Currently Being Moderated
    cj wrote:
    Try disabling SELinux. On Oracle Linux you would edit /etc/selinux/config, set SELINUX to DISABLED, and reboot. Also see the setenforce command.
    Yes !!!!!!!!

    Thanks man it worked !! It was SELinux which was blocking the library load. Now I have OCI8 entry in phpinfo(). At the same time as we saw before the PHP in command line could detect OCI8, maybe this means that SELinux doesn't have the same impact in CLI as in GUI. Conclusion, you were totally correct about defining the environment variables in /etc/syscnfig/httpd. The variables were actually defined (with a slight difference in syntax that I will show below), yet SELinux prevented PHP from loading the oracle libraray.

    I also wrote a test SQL script (SELECT employee_id FROM employees WHERE department_id = 100) and the result was printed on the screen perfectly.

    So for those who may have encountered the same problem with the same environment parameters I'm going to give a summary of how I proceeded in the case where it might be helpful for others.

    My environment
    OS: Linux Fedora Core 17 (X86_64)
    Oracle version: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit
    Apache version (httpd): Apache 2.0
    PHP version: 5.4.13
    Before the installation
    Before the installation I disabled SELinux. At the time of writing I'm not an expert of SELinux so I don't know any rule modification in order to modify SELinux policy accordingly allowing to OCI8 module to load oracle libraries. As a result I finally disabled completely the SELinux on my system which may have serious security impacts! This can be done in the following way (being as root)
    # vim  /etc/selinux/config
    The file content is something similar to the following
    # This file controls the state of SELinux on the system.
    # SELINUX= can take one of these three values:
    #     enforcing - SELinux security policy is enforced.
    #     permissive - SELinux prints warnings instead of enforcing.
    #     disabled - No SELinux policy is loaded.
    SELINUX=enforcing
    # SELINUXTYPE= can take one of these two values:
    #     targeted - Targeted processes are protected,
    #     minimum - Modification of targeted policy. Only selected processes are protected. 
    #     mls - Multi Level Security protection.
    SELINUXTYPE=targeted 
    So what I did was that I put a comment at the beginning of the line SELINUX=enforcing and instead I added a new line right after that line which was SELINUX=disabled.

    Finally I rebooted the system.


    Installation:
    - Make sure that all oracle environment variables are defined in ~/.bash_profile of the user who installs OCI8. Otherwise you will have to enter manually the path to $ORACLE_HOME. I tested both ways and each method works pretty well. Yet I find the first one more elegant because it detects automatically everything

    - In my case, PHP, Apache and Oracle server were all on the same physical machine, therefore I didn't need to install the Oracle Instant client*. All the required oracle libraries for OCI8 were therefore already available.

    - being as ROOT, I run the following (I don't know whether this was mandatory but I prefered to stop httpd before installing OCI8)
    # pecl install oci8
    (On my machine pecl was already there, if not you can install it by using yum)

    - Once installation is over, at the end of the installation report in the terminal you will get something like this
    >
    Build process completed successfully
    Installing '/usr/lib64/php/modules/oci8.so'
    install ok: channel://pecl.php.net/oci8-1.4.9
    configuration option "php_ini" is not set to php.ini location
    You should add "extension=oci8.so" to php.ini
    >
    The two bold lines above shows what you have to put in your php.ini file (on my computer this file is in */etc/php.ini* )
    So I updated the php.ini file in the following way:
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; Dynamic Extensions ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     
    ; If you wish to have an extension loaded automatically, use the following
    ; syntax:
    ;
    ;   extension=modulename.extension
                           .
                           .
                           .
    extension=oci8.so
                           .
                           .
                           .
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; Paths and Directories ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     
    ; UNIX: "/path1:/path2"
    ;
    ;
                           .
                           .
                           .
    extension_dir="/usr/lib64/php/modules"
    Then you have to define the required oracle environment variables for Apache. According to what I read in http://www.oracle.com/technetwork/topics/php/underground-php-oracle-manual-098250.html and in several forums while I was googling for this problem and also based on my own tests, it seems to me that depending on which Apache version you're using, the syntax for declaring the environment variables in */etc/sysconfig/httpd* is not the same.

    Here is what I added at the end of the file /etc/sysconfig/httpd
    .
    .
    .
    ORACLE_BASE=/u01/app/oracle
    ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
    LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/db_1/lib:/u01/app/oracle/product/11.2.0/db_1/network/lib
    TNS_ADMIN=/u01/app/oracle/product/11.2.0/db_1/network/admin
    NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252
    ORACLE_SID=db01
    I tried to use the export keyword before the variable names but it didn't work for me, yet I saw in other forums that there were people who apparently had used that syntax successfully. So again it is a matter of personal observation. For me using Apache 2.0, only the above syntax works. Also if I use $ in order to expand the environment variables it doesn't work
    so for example instead of writing
    ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
    LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/network/lib
    I had to write explicitly the expanded values myself, that is,
    ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
    LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/db_1/lib:/u01/app/oracle/product/11.2.0/db_1/network/lib
    Once this is done, restart httpd
    # service httpd start
    If everything went well, normally you will see the OCI8 entry if you run phpinfo() in a test PHP script.

    Hope this may help others,

    Once again, thanks a lot to cj for his time and his valuable help for solving my problem.


    Regards,
    Dariyoosh
  • 5. Re: Unable load  library '/usr/lib64/php/modules/oci8.so' - libclntsh.so.11.1
    cj Employee ACE
    Currently Being Moderated
    Thanks for giving enough detail in the problem description to help spot a potential resolution. Also thanks for posting the resolution summary.

    Perhaps the /etc/sysconfig/httpd variable format requirements on Fedora are different due to Fedora's use of systemd?

    You might want to check out Fedora's SELinux and httpd to see if you can re-enable SELinux. Oracle 11.2 itself works with SELinux: "Starting with Oracle Database 11g Release 2 (11.2), the Security Enhanced Linux (SELinux) feature is supported for Oracle Linux 4, Red Hat Enterprise Linux 4, Oracle Linux 5, and Red Hat Enterprise Linux 5." (from http://docs.oracle.com/cd/E11882_01/install.112/e24321.pdf)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points