dariyoosh Posted April 3, 2013 Share Posted April 3, 2013 Hello everybody, I'm trying to setup a connection from PHP to an oracle database by using OCI8. According to the documentation, upon a successfull installation, I'm supposed to see some information about OCI8 in phpinfo(). Problem: Nothing shows up in phpinfo about OCI8 Just to see what would be the output I run the very same PHP test script in the article <?php $conn = oci_connect('myuser', 'mypassword', 'localhost/DB01'); $stid = oci_parse($conn, 'select table_name from user_tables'); oci_execute($stid); echo "<table>\n"; while ( ( $row = oci_fetch_array ( $stid, OCI_ASSOC+OCI_RETURN_NULLS ) ) != false ) { echo "<tr>\n"; foreach ($row as $item) { echo " <td>". ($item !== null ? htmlentities($item, ENT_QUOTES) : " ")."</td>\n"; } echo "</tr>\n"; } echo "</table>\n"; ?> And the output was Fatal error: Call to undefined function oci_connect() in /var/www/html/myscript.php on line ... Which shows that something serious is missing. As a result, I would like to ask you to kindly take a look to the below details about how I proceeded in order to setup OCI8 and to see where I made mistake(s) Here are some details about my working platform OS: Linux Fedora Core 17 (64 bits) DBMS: Oracle Enterprise Edition 11gR2 (11.2.0.1.0) PHP Version: 5.4.13 Apache version: 2.2.23 I installed OCI8 based on the following article (except that I already had both server and client installed on the same physical machine, therefore I didn't need to install/reinstall the instant client) http://www.oracle.com/technetwork/articles/technote-php-instant-084410.html So being as ROOT I run the following # pecl install oci8 Which gave me the following output # pecl install oci8downloading oci8-1.4.9.tgz ...Starting to download oci8-1.4.9.tgz (169,255 bytes).....................................done: 169,255 bytes10 source files, buildingrunning: phpizeConfiguring for:PHP Api Version: 20100412Zend Module Api No: 20100525Zend Extension Api No: 220100525Please provide the path to the ORACLE_HOME directory. Use 'instantclient,/path/to/instant/client/lib' if you're compiling with Oracle Instant Client [autodetect] : /u01/app/oracle/product/11.2.0/db_1building in /var/tmp/pear-build-dariyooshszFGdb/oci8-1.4.9running: /var/tmp/oci8/configure --with-oci8=/u01/app/oracle/product/11.2.0/db_1checking for grep that handles long lines and -e... /usr/bin/grepchecking for egrep... /usr/bin/grep -Echecking for a sed that does not truncate output... /usr/bin/sedchecking for cc... ccchecking whether the C compiler works... yeschecking for C compiler default output file name... a.outchecking for suffix of executables...checking whether we are cross compiling... nochecking for suffix of object files... ochecking whether we are using the GNU C compiler... yeschecking whether cc accepts -g... yeschecking for cc option to accept ISO C89... none neededchecking how to run the C preprocessor... cc -Echecking for icc... nochecking for suncc... nochecking whether cc understands -c and -o together... yeschecking for system library directory... libchecking if compiler supports -R... nochecking if compiler supports -Wl,-rpath,... yeschecking build system type... x86_64-unknown-linux-gnuchecking host system type... x86_64-unknown-linux-gnuchecking target system type... x86_64-unknown-linux-gnuchecking for PHP prefix... /usrchecking 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/libchecking for PHP extension directory... /usr/lib64/php/moduleschecking for PHP installed headers prefix... /usr/include/phpchecking if debug is enabled... nochecking if zts is enabled... nochecking for re2c... noconfigure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.checking for gawk... gawkchecking for Oracle Database OCI8 support... yes, sharedchecking PHP version... 5.4.13, okchecking for ANSI C header files... yeschecking for sys/types.h... yeschecking for sys/stat.h... yeschecking for stdlib.h... yeschecking for string.h... yeschecking for memory.h... yeschecking for strings.h... yeschecking for inttypes.h... yeschecking for stdint.h... yeschecking for unistd.h... yeschecking size of long int... 8checking checking if we're on a 64-bit platform... yeschecking Oracle ORACLE_HOME install directory... /u01/app/oracle/product/11.2.0/db_1checking ORACLE_HOME library validity... libchecking Oracle library version compatibility... 11.1checking how to print strings... printfchecking for a sed that does not truncate output... (cached) /usr/bin/sedchecking for fgrep... /usr/bin/grep -Fchecking for ld used by cc... /usr/bin/ldchecking if the linker (/usr/bin/ld) is GNU ld... yeschecking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -Bchecking the name lister (/usr/bin/nm - B) interface... BSD nmchecking whether ln -s works... yeschecking the maximum length of command line arguments... 1572864checking whether the shell understands some XSI constructs... yeschecking whether the shell understands "+="... yeschecking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noopchecking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noopchecking for /usr/bin/ld option to reload object files... -rchecking for objdump... objdumpchecking how to recognize dependent libraries... pass_allchecking for dlltool... nochecking how to associate runtime and link libraries... printf %s\nchecking for ar... archecking for archiver @FILE support... @checking for strip... stripchecking for ranlib... ranlibchecking for gawk... (cached) gawkchecking command to parse /usr/bin/nm -B output from cc object... okchecking for sysroot... nochecking for mt... nochecking if : is a manifest tool... nochecking for dlfcn.h... yeschecking for objdir... .libschecking if cc supports -fno-rtti -fno-exceptions... nochecking for cc option to produce PIC... -fPIC -DPICchecking if cc PIC flag -fPIC -DPIC works... yeschecking if cc static flag -static works... nochecking if cc supports -c -o file.o... yeschecking if cc supports -c -o file.o... (cached) yeschecking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yeschecking whether -lc should be explicitly linked in... nochecking dynamic linker characteristics... GNU/Linux ld.sochecking how to hardcode library paths into programs... immediatechecking whether stripping libraries is possible... yeschecking if libtool supports shared libraries... yeschecking whether to build shared libraries... yeschecking whether to build static libraries... noconfigure: creating ./config.statusconfig.status: creating config.hconfig.status: executing libtool commandsrunning: make/bin/sh /var/tmp/pear-build-dariyooshszFGdb/oci8-1.4.9/libtool --mode=compile cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-dariyooshszFGdb/oci8-1.4.9/include -I/var/tmp/pear-build-dariyooshszFGdb/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.lolibtool: compile: cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-dariyooshszFGdb/oci8-1.4.9/include -I/var/tmp/pear-build-dariyooshszFGdb/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-dariyooshszFGdb/oci8-1.4.9/libtool --mode=compile cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-dariyooshszFGdb/oci8-1.4.9/include -I/var/tmp/pear-build-dariyooshszFGdb/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.lolibtool: compile: cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-dariyooshszFGdb/oci8-1.4.9/include -I/var/tmp/pear-build-dariyooshszFGdb/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-dariyooshszFGdb/oci8-1.4.9/libtool --mode=compile cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-dariyooshszFGdb/oci8-1.4.9/include -I/var/tmp/pear-build-dariyooshszFGdb/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.lolibtool: compile: cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-dariyooshszFGdb/oci8-1.4.9/include -I/var/tmp/pear-build-dariyooshszFGdb/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-dariyooshszFGdb/oci8-1.4.9/libtool --mode=compile cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-dariyooshszFGdb/oci8-1.4.9/include -I/var/tmp/pear-build-dariyooshszFGdb/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.lolibtool: compile: cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-dariyooshszFGdb/oci8-1.4.9/include -I/var/tmp/pear-build-dariyooshszFGdb/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-dariyooshszFGdb/oci8-1.4.9/libtool --mode=compile cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-dariyooshszFGdb/oci8-1.4.9/include -I/var/tmp/pear-build-dariyooshszFGdb/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.lolibtool: compile: cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-dariyooshszFGdb/oci8-1.4.9/include -I/var/tmp/pear-build-dariyooshszFGdb/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-dariyooshszFGdb/oci8-1.4.9/libtool --mode=link cc -DPHP_ATOM_INC -I/var/tmp/pear-build-dariyooshszFGdb/oci8-1.4.9/include -I/var/tmp/pear-build-dariyooshszFGdb/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-dariyooshszFGdb/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 -lclntshlibtool: 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.solibtool: link: ( cd ".libs" && rm -f "oci8.la" && ln -s "../oci8.la" "oci8.la" )/bin/sh /var/tmp/pear-build-dariyooshszFGdb/oci8-1.4.9/libtool --mode=install cp ./oci8.la /var/tmp/pear-build-dariyooshszFGdb/oci8-1.4.9/moduleslibtool: install: cp ./.libs/oci8.so /var/tmp/pear-build-dariyooshszFGdb/oci8-1.4.9/modules/oci8.solibtool: install: cp ./.libs/oci8.lai /var/tmp/pear-build-dariyooshszFGdb/oci8-1.4.9/modules/oci8.lalibtool: finish: PATH="/usr/bin:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/dariyoosh/.local/bin:/home/dariyoosh/bin:/usr/local/jdk1.7.0_17/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/u01/app/oracle/product/11.2.0/db_1/bin:/usr/local/texlive/2011/bin/x86_64-linux:/opt/libreoffice4.0/program/soffice:/usr/local/apache-tomcat-7.0.37/bin:/sbin" ldconfig -n /var/tmp/pear-build-dariyooshszFGdb/oci8-1.4.9/modules----------------------------------------------------------------------Libraries have been installed in: /var/tmp/pear-build-dariyooshszFGdb/oci8-1.4.9/modulesIf you ever happen to want to link against installed librariesin a given directory, LIBDIR, you must either use libtool, andspecify 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 formore information, such as the ld(1) and ld.so( manual pages.----------------------------------------------------------------------Build complete.Don't forget to run 'make test'.running: make INSTALL_ROOT="/var/tmp/pear-build-dariyooshszFGdb/install-oci8-1.4.9" installInstalling shared extensions: /var/tmp/pear-build-dariyooshszFGdb/install-oci8-1.4.9/usr/lib64/php/modules/running: find "/var/tmp/pear-build-dariyooshszFGdb/install-oci8-1.4.9" | xargs ls -dils3164435 4 drwxr-xr-x. 3 root root 4096 Apr 3 12:00 /var/tmp/pear-build-dariyooshszFGdb/install-oci8-1.4.93164467 4 drwxr-xr-x. 3 root root 4096 Apr 3 12:00 /var/tmp/pear-build-dariyooshszFGdb/install-oci8-1.4.9/usr3164469 4 drwxr-xr-x. 3 root root 4096 Apr 3 12:00 /var/tmp/pear-build-dariyooshszFGdb/install-oci8-1.4.9/usr/lib643164470 4 drwxr-xr-x. 3 root root 4096 Apr 3 12:00 /var/tmp/pear-build-dariyooshszFGdb/install-oci8-1.4.9/usr/lib64/php3164474 4 drwxr-xr-x. 2 root root 4096 Apr 3 12:00 /var/tmp/pear-build-dariyooshszFGdb/install-oci8-1.4.9/usr/lib64/php/modules3164466 596 -rwxr-xr-x. 1 root root 606873 Apr 3 12:00 /var/tmp/pear-build-dariyooshszFGdb/install-oci8-1.4.9/usr/lib64/php/modules/oci8.soBuild process completed successfullyInstalling '/usr/lib64/php/modules/oci8.so'install ok: channel://pecl.php.net/oci8-1.4.9configuration option "php_ini" is not set to php.ini locationYou should add "extension=oci8.so" to php.ini# After that I added to php.ini ;;;;;;;;;;;;;;;;;;;;;;; Dynamic Extensions ;;;;;;;;;;;;;;;;;;;;;;;; If you wish to have an extension loaded automatically, use the following; syntax:;; extension=modulename.extension;; For example, on Windows:;; extension=msql.dll;; ... or under UNIX:;; extension=msql.soextension="oci8.so";; ... or with a path:;; extension=/path/to/extension/msql.so . . . extension_dir="/usr/lib64/php/modules" I also run the following command in the terminal # php --ri oci8oci8OCI8 Support => enabledVersion => 1.4.9Revision => $Id: e2241cffb72c940cb2ca267b7a6a0ce436de7e5e $Active Persistent Connections => 0Active Connections => 0Oracle Run-time Client Library Version => 11.2.0.1.0Oracle Version => 11.2Compile-time ORACLE_HOME => /u01/app/oracle/product/11.2.0/db_1Libraries Used => -Wl,-rpath,/u01/app/oracle/product/11.2.0/db_1/lib -L/u01/app/oracle/product/11.2.0/db_1/lib -lclntshTemporary Lob support => enabledCollections support => enabledDirective => Local Value => Master Valueoci8.max_persistent => -1 => -1oci8.persistent_timeout => -1 => -1oci8.ping_interval => 60 => 60oci8.privileged_connect => Off => Offoci8.statement_cache_size => 20 => 20oci8.default_prefetch => 100 => 100oci8.old_oci_close_semantics => Off => Offoci8.connection_class => no value => no valueoci8.events => Off => Off[root@localhost ~]# So looking at the above bold output, I think we can say that there is however some link between the installed oci and my oracle server. Also, I added to the /etc/sysconfig/httpd configuration file the following environment variables which had already been defined in ~/.bash_profile # Configuration file for the httpd service.## Note: With previous versions of httpd, the MPM could be changed by# editing an "HTTPD" variable here. With the current version, that# variable is now ignored. A particular systemd service must be# chosen corresponding to the desired MPM:## httpd.service => prefork MPM# httpd-worker.service => worker MPM# httpd-event.service => event MPM## Use systemctl to stop/start between MPMs, and to disable/enable# whichever service is required to start at boot time.### To pass additional options (for instance, -D definitions) to the# httpd binary at startup, set OPTIONS here.##OPTIONS=## This setting ensures the httpd process is started in the "C"# locale by default:#LANG=C PassEnv ORACLE_BASEPassEnv ORACLE_HOMEPassEnv LD_LIBRARY_PATH64PassEnv LD_LIBRARY_PATHPassEnv TNS_ADMINPassEnv NLS_LANGPassEnv ORACLE_SID Once the variables were defined I restarted the httpd service httpd restart Yet, the same problem, no oci8 in phpinfo() Could someone kindly make some clarification? Thanks in advance, Dariyoosh Link to comment https://forums.phpfreaks.com/topic/276480-why-there-is-nothing-about-oci8-in-phpinfo-for-oracle-database-connections-once-oci8-has-been-installed/ Share on other sites More sharing options...
kicken Posted April 3, 2013 Share Posted April 3, 2013 Load up a page via your webserver that outputs phpinfo() and then look for the Loaded Configuration File entry. It's common that the webserver uses a different php.ini file than the CLI version of PHP. You will need to make sure you add the extension in both php.ini files. Link to comment https://forums.phpfreaks.com/topic/276480-why-there-is-nothing-about-oci8-in-phpinfo-for-oracle-database-connections-once-oci8-has-been-installed/#findComment-1422677 Share on other sites More sharing options...
dariyoosh Posted April 3, 2013 Author Share Posted April 3, 2013 Hello there, Thank you very much for your attention to my problem. First of all, after a bit googling I understood that the environment variables inside /etc/sysconfig/httpd as I specified by using PassEnv are those used internally by apache and have nothing to do with the OS environment variables. Apparently for OS environment variables the same syntax applies as ~/.bash_profile. So instead of adding PassEnv ORACLE_BASEPassEnv ORACLE_HOMEPassEnv LD_LIBRARY_PATH64PassEnv LD_LIBRARY_PATHPassEnv TNS_ADMINPassEnv NLS_LANGPassEnv ORACLE_SID I added the following lines at the end of /etc/sysconfig/httpd ORACLE_BASE=/u01/app/oracleexport ORACLE_BASEORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1export ORACLE_HOMELD_LIBRARY_PATH64=$LD_LIBRARY_PATH64:$ORACLE_HOME/lib:$ORACLE_HOME/network/libexport LD_LIBRARY_PATH64LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LD_LIBRARY_PATH64export LD_LIBRARY_PATHTNS_ADMIN=$ORACLE_HOME/network/adminexport TNS_ADMINNLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252export NLS_LANGORACLE_SID=db01export ORACLE_SID However, I'm not sure that these variables are actually being taken into account by Apache because when I restart the server, here is what I can read in the log file # cat /var/log/httpd/error_log[Wed Apr 03 20:37:27 2013] [notice] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0[Wed Apr 03 20:37:27 2013] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)[Wed Apr 03 20:37:27 2013] [notice] Digest: generating secret for digest authentication ...[Wed Apr 03 20:37:27 2013] [notice] Digest: donePHP 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[Wed Apr 03 20:37:27 2013] [warn] mod_wsgi: Compiled for Python/2.7.2.[Wed Apr 03 20:37:27 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.[Wed Apr 03 20:37:27 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# Looking for the missing file # locate libclntsh.so.11.1/home/oracle/oracle_extract_folder/database/stage/ext/lib/libclntsh.so.11.1/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.11.1 Yet /u01/app/oracle/product/11.2.0/db_1/lib/ is exactly what I specified as LD_LIBRARY_PATH in /etc/sysconfig/httpd. So it seems that (maybe) apache doesn't see my environment variables. Load up a page via your webserver that outputs phpinfo() and then look for the Loaded Configuration File entry. I proceeded accordingly as you said when I see the output of the phpinfo() in my browser I have Loaded Configuration File = /etc/php.ini It's common that the webserver uses a different php.ini file than the CLI version of PHP Very interesting, I didn't even know that there are two different php.ini files However, it seems that on my system both of them point to the same file # php -i | grep Configuration Configuration File (php.ini) Path => /etc Loaded Configuration File => /etc/php.ini Configuration # I'm really confused ! Regards, Dariyoosh Link to comment https://forums.phpfreaks.com/topic/276480-why-there-is-nothing-about-oci8-in-phpinfo-for-oracle-database-connections-once-oci8-has-been-installed/#findComment-1422717 Share on other sites More sharing options...
dariyoosh Posted April 5, 2013 Author Share Posted April 5, 2013 Ok, I solved the problem. 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.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 environmentOS: Linux Fedora Core 17 (X86_64)Oracle version: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bitApache version (httpd): Apache 2.0PHP version: 5.4.13Before the installationBefore 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 successfullyInstalling '/usr/lib64/php/modules/oci8.so'install ok: channel://pecl.php.net/oci8-1.4.9configuration option "php_ini" is not set to php.ini locationYou 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 workso 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, Regards,Dariyoosh Link to comment https://forums.phpfreaks.com/topic/276480-why-there-is-nothing-about-oci8-in-phpinfo-for-oracle-database-connections-once-oci8-has-been-installed/#findComment-1423049 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.