Topic: PHP et oracle

Bonjour,

Je commence à désespérer !!

Je souhate installer OCI8 avec php. J'ai suivi ce tuto : http://doc.fedora-fr.org/wiki/PHP_:_acc … 9es_Oracle

J'ai installé oracle database, et non oracle instant client, ca devrait tout de même fonctionner non?

La base de données fonctionne bien, je me suis créer une BD, un user et un espace, tout fonctionne. Pour être certain je me suis connecté avec sqlplus avec mon nouvel utilisateur et j'ai créé une table, tout est ok.

Lorsque je démarre apache, j'obtiens les erreurs suivantes:

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
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
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo_oci.so' - libclntsh.so.11.1: cannot open shared object file: No such file or directory in Unknown on line 0


Voici quelques infos de plus:

>echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0/dbhome_1
>echo $LD_LIBRARY_PATH
/u01/app/oracle/product/11.2.0/dbhome_1/lib:/lib:/usr/lib

SELINUX est disabled

Les permissions de $ORACLE_HOME/lib sont 755 avec oracle comme utilisateur et oinstall comme groupe.

>ls -l $ORACLE_HOME/lib | grep libclntsh
-rwxr-xr-x  1 oracle oinstall  48725849 Mar 16 17:51 libclntsh.so
lrwxrwxrwx. 1 oracle oinstall        56 Mar 16 17:50 libclntsh.so.10.1 -> /u01/app/oracle/product/11.2.0/dbhome_1/lib/libclntsh.so
-rwxr-xr-x. 1 oracle oinstall  48725849 Mar 16 17:51 libclntsh.so.11.1


Est-ce que j'ai fais quelque chose de mal ?!

Merci beaucoup !

Re: PHP et oracle

LD_LIBRARY_PATH doit être définit dans l'environnement de l'utilisateur apache (comme indiqué dans le tuto...)

Le plus simple est donc de l'ajouter dans le fichier /etc/sysconfig/httpd et de relancer le service.

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: PHP et oracle

Oui j'ai ceci dans mon fichier /etc/sysconfig/httpd:

export LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/dbhome_1/lib
export NLS_LANG=FRENCH_FRANCE.AL32UTF8
export TNS_ADMIN=/u01/app/oracle

Re: PHP et oracle

C'est une version 32 ou 64 bits d'Oracle ?

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: PHP et oracle

64 bits ! Pitié dis moi pas que je dois réinstaller oracle en 32 bits !! J'ai tellement rusher pour l'installer...

Re: PHP et oracle

Non, non, c'est bon, puisque c'est un php 64bits, il faut un client Oracle 64bits.

La, je vois pas trop...

En ligne de commande, que retourne

ldd /usr/lib64/php/modules/oci8.so
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: PHP et oracle

>ldd /usr/lib64/php/modules/oci8.so
        linux-vdso.so.1 =>  (0x00007fffa81a4000)
    libclntsh.so.11.1 => /u01/app/oracle/product/11.2.0/dbhome_1/lib/libclntsh.so.11.1 (0x00007fb80b6af000)
    libc.so.6 => /lib64/libc.so.6 (0x00007fb80b2e0000)
    libnnz11.so => /u01/app/oracle/product/11.2.0/dbhome_1/lib/libnnz11.so (0x00007fb80af18000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007fb80ad14000)
    libm.so.6 => /lib64/libm.so.6 (0x00007fb80aa8f000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fb80a873000)
    libnsl.so.1 => /lib64/libnsl.so.1 (0x00007fb80a659000)
    libaio.so.1 => /lib64/libaio.so.1 (0x00007fb80a457000)
    /lib64/ld-linux-x86-64.so.2 (0x00000031c8000000)

Re: PHP et oracle

Et "php -v" ça marche ou ça met aussi une erreur sur libclntsh.so.11.1 ?

php -v
php -i | grep -i oci
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

9 (edited by jnbrunet 2012-03-17 19:01:49)

Re: PHP et oracle

>php -v
PHP Warning:  Module 'oci8' already loaded in Unknown on line 0
PHP 5.3.10 (cli) (built: Feb  4 2012 08:18:10)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

Re: PHP et oracle

>php -i | grep -i oci:

PHP Warning:  Module 'oci8' already loaded in Unknown on line 0
Configure Command =>  './configure'  '--build=x86_64-unknown-linux-gnu' '--host=x86_64-unknown-linux-gnu' '--program-prefix=' '--disable-dependency-tracking' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib64' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear' '--with-bz2' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--with-xpm-dir=/usr' '--enable-gd-native-ttf' '--with-t1lib=/usr' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--with-kerberos' '--enable-ucd-snmp-hack' '--enable-shmop' '--enable-calendar' '--with-libxml-dir=/usr' '--enable-xml' '--with-system-tzdata' '--with-mhash' '--enable-force-cgi-redirect' '--libdir=/usr/lib64/php' '--enable-pcntl' '--with-imap=shared' '--with-imap-ssl' '--enable-mbstring=shared' '--enable-mbregex' '--with-gd=shared' '--enable-bcmath=shared' '--enable-dba=shared' '--with-db4=/usr' '--with-xmlrpc=shared' '--with-ldap=shared' '--with-ldap-sasl' '--enable-mysqlnd=shared' '--with-mysql=shared,mysqlnd' '--with-mysqli=shared,mysqlnd' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-oci8=shared,instantclient,/usr/lib64/oracle/11.2/client64/lib,11.2' '--with-pdo-oci=shared,instantclient,/usr,11.2' '--with-interbase=shared,/usr/lib64/firebird' '--with-pdo-firebird=shared,/usr/lib64/firebird' '--enable-dom=shared' '--with-pgsql=shared' '--enable-wddx=shared' '--with-snmp=shared,/usr' '--enable-soap=shared' '--with-xsl=shared,/usr' '--enable-xmlreader=shared' '--enable-xmlwriter=shared' '--with-curl=shared,/usr' '--enable-fastcgi' '--enable-pdo=shared' '--with-pdo-odbc=shared,unixODBC,/usr' '--with-pdo-mysql=shared,mysqlnd' '--with-pdo-pgsql=shared,/usr' '--with-pdo-sqlite=shared,/usr' '--with-pdo-dblib=shared,/usr' '--with-sqlite3=shared,/usr' '--with-sqlite=shared,/usr' '--enable-json=shared' '--enable-zip=shared' '--without-readline' '--with-libedit' '--with-pspell=shared' '--enable-phar=shared' '--with-mcrypt=shared,/usr' '--with-tidy=shared,/usr' '--with-mssql=shared,/usr' '--enable-sysvmsg=shared' '--enable-sysvshm=shared' '--enable-sysvsem=shared' '--enable-posix=shared' '--with-unixODBC=shared,/usr' '--enable-fileinfo=shared' '--enable-intl=shared' '--with-icu-dir=/usr' '--with-enchant=shared,/usr' '--with-recode=shared,/usr'
/etc/php.d/oci8.ini,
/etc/php.d/pdo_oci.ini,
PHP Warning:  Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in Unknown on line 0
oci8
OCI8 Support => enabled
oci8.connection_class => no value => no value
oci8.default_prefetch => 100 => 100
oci8.events => Off => Off
oci8.max_persistent => -1 => -1
oci8.old_oci_close_semantics => Off => Off
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
PDO drivers => oci, sqlite
PDO_OCI
PDO Driver for OCI 8 and later => enabled

Re: PHP et oracle

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

ça c'est que la directive "extension=oci8.so" est dans 2 .ini
Normalement, elle est fournie dans /etc/php.d/oci8.ini, pas la peine de la rajouter ailleurs.

Enfin, c'est juste un warning.
Donc l'exntension fonctionne en ligne de commande
Donc pour apache, c'est l'environnement qui n'est pas complet

Voir toute les références à Oracle dans l'environnement courant, et les mettres dans la conf d'apache et relancer le service (peut-être ORACLE_HOME)

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

12 (edited by jnbrunet 2012-03-17 19:14:09)

Re: PHP et oracle

Bizarre lorsque j'essaie de poster une réponse le forum me répond : Too more links in message. Allowed 1 links. Reduce number of links and post it again.

En tout cas...j'ai copié ce que j'avais dans mon .bashrc:

>cat /etc/sysconfig/httpd
# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

#ORACLE_HOSTNAME=fedora16.localdomain
export ORACLE_HOSTNAME=studioxps
#ORACLE_UNQNAME=DB11G
export ORACLE_UNQNAME=orcl
#ORACLE_BASE=/u01/app/oracle
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=IFT2935
export ORACLE_TERM=xterm
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
if [ $USER = "oracle" ]; then
  if [ $SHELL = "/bin/ksh" ]; then
    ulimit -p 16384
    ulimit -n 65536
  else
    ulimit -u 16384 -n 65536
  fi
fi


export NLS_LANG=FRENCH_FRANCE.AL32UTF8
export TNS_ADMIN=/u01/app/oracle


Toujours la meme erreur:

cat /var/log/httpd/error_log
[Sat Mar 17 15:10:38 2012] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Sat Mar 17 15:10:38 2012] [warn] module php5_module is already loaded, skipping
[Sat Mar 17 15:10:38 2012] [notice] Digest: generating secret for digest authentication ...
[Sat Mar 17 15:10:38 2012] [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
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
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo_oci.so' - libclntsh.so.11.1: cannot open shared object file: No such file or directory in Unknown on line 0
[Sat Mar 17 15:10:38 2012] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.10 configured -- resuming normal operations

Re: PHP et oracle

La valeur de TNS_ADMIN n'est pas bonne non plus, ça doit être le chemin du tnsnames.ora, et elle doit être facultative (de mémoire), si ORACLE_HOME et définie (dans le cas il utilise $ORACLE_HOME/network/admin)

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: PHP et oracle

J'ai essayé avec export TNS_ADMIN=$ORACLE_HOME/network/admin

Toujours pas...

Est-ce qu'on est certain que apache exécute bien /etc/sysconfig/httpd ? J'imagine que oui...

Re: PHP et oracle

Arg... sous fedora 16 ?
Le fichier de config apache est analysé par systemd, donc ce n'est plus de la syntaxe "bash" mais juste une liste de variable...

Essaie en mettant

ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
ORACLE_SID=IFT2935
LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/dbhome_1/lib

Après une autre solution à tester

echo /u01/app/oracle/product/11.2.0/dbhome_1/lib  > /etc/ld.so.conf.d/oracle.conf
ldconfig
systemctl restart httpd.service

P.S. je devrais rendre la signature avec les info système obligatoire....

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

16 (edited by jnbrunet 2012-03-17 19:27:02)

Re: PHP et oracle

Oh yeah !!

MERCI BEAUCOUP !

Le problème était donc la syntaxe du fichier de config ! En mettant:

ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
ORACLE_SID=IFT2935
LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/dbhome_1/lib

Ca fonctionne !

P.S Oui effectivement, je sais pas pourquoi je ne l'ai pas mentionner, fedora 16, grrr

Re: PHP et oracle

Super !

Du coup, j'en ai profité pour corriger la documentation.

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