Debian Jessie + PHP + OCI8

Comment installer le connecteur OCI8 pour php5 sur Debian (8.x) aka Jessie .

  • Debian 8.6 x86-64
  • Oracle Instant Client 11.2

Préparation :

apt-get install build-essential php5-dev php-pear libaio1 unzip

Télécharger l’Oracle Instant Client  (basic et sdk ) depuis le site d’Oracle :

# cp *.zip /usr/local/lib/
# cd /usr/local/lib/
# unzip instantclient-sdk-linux.x64-11.2.0.4.0.zip 
Archive:  instantclient-sdk-linux.x64-11.2.0.4.0.zip
   creating: instantclient_11_2/sdk/
   creating: instantclient_11_2/sdk/include/
  inflating: instantclient_11_2/sdk/include/occi.h  
  inflating: instantclient_11_2/sdk/include/occiCommon.h  
  inflating: instantclient_11_2/sdk/include/occiControl.h  
  inflating: instantclient_11_2/sdk/include/occiData.h  
  inflating: instantclient_11_2/sdk/include/occiObjects.h  
  inflating: instantclient_11_2/sdk/include/occiAQ.h  
  inflating: instantclient_11_2/sdk/include/oci.h  
  inflating: instantclient_11_2/sdk/include/oci1.h  
  inflating: instantclient_11_2/sdk/include/oci8dp.h  
  inflating: instantclient_11_2/sdk/include/ociap.h  
  inflating: instantclient_11_2/sdk/include/ociapr.h  
  inflating: instantclient_11_2/sdk/include/ocidef.h  
  inflating: instantclient_11_2/sdk/include/ocidem.h  
  inflating: instantclient_11_2/sdk/include/ocidfn.h  
  inflating: instantclient_11_2/sdk/include/ociextp.h  
  inflating: instantclient_11_2/sdk/include/ocikpr.h  
  inflating: instantclient_11_2/sdk/include/ocixmldb.h  
  inflating: instantclient_11_2/sdk/include/ocixstream.h  
  inflating: instantclient_11_2/sdk/include/odci.h  
  inflating: instantclient_11_2/sdk/include/oratypes.h  
  inflating: instantclient_11_2/sdk/include/ori.h  
  inflating: instantclient_11_2/sdk/include/orid.h  
  inflating: instantclient_11_2/sdk/include/orl.h  
  inflating: instantclient_11_2/sdk/include/oro.h  
  inflating: instantclient_11_2/sdk/include/ort.h  
  inflating: instantclient_11_2/sdk/include/xa.h  
  inflating: instantclient_11_2/sdk/include/nzt.h  
  inflating: instantclient_11_2/sdk/include/nzerror.h  
  inflating: instantclient_11_2/sdk/include/ldap.h  
   creating: instantclient_11_2/sdk/demo/
  inflating: instantclient_11_2/sdk/demo/demo.mk  
  inflating: instantclient_11_2/sdk/demo/cdemo81.c  
  inflating: instantclient_11_2/sdk/demo/occidemo.sql  
  inflating: instantclient_11_2/sdk/demo/occidemod.sql  
  inflating: instantclient_11_2/sdk/demo/occidml.cpp  
  inflating: instantclient_11_2/sdk/demo/occiobj.cpp  
  inflating: instantclient_11_2/sdk/demo/occiobj.typ  
  inflating: instantclient_11_2/sdk/SDK_README  
 extracting: instantclient_11_2/sdk/ottclasses.zip  
  inflating: instantclient_11_2/sdk/ott  
# unzip instantclient-basic-linux.x64-11.2.0.4.0.zip 
Archive:  instantclient-basic-linux.x64-11.2.0.4.0.zip
  inflating: instantclient_11_2/BASIC_README  
  inflating: instantclient_11_2/adrci  
  inflating: instantclient_11_2/genezi  
  inflating: instantclient_11_2/libclntsh.so.11.1  
  inflating: instantclient_11_2/libnnz11.so  
  inflating: instantclient_11_2/libocci.so.11.1  
  inflating: instantclient_11_2/libociei.so  
  inflating: instantclient_11_2/libocijdbc11.so  
  inflating: instantclient_11_2/ojdbc5.jar  
  inflating: instantclient_11_2/ojdbc6.jar  
  inflating: instantclient_11_2/uidrvci  
  inflating: instantclient_11_2/xstreams.jar  
# cd instantclient_11_2/
# ls -al
total 183536
drwxr-sr-x 3 root staff      4096 Nov 22 16:30 .
drwxrwsr-x 5 root staff      4096 Nov 22 16:30 ..
-rwxrwxr-x 1 root staff     25420 Aug 24  2013 adrci
-rw-rw-r-- 1 root staff       439 Aug 24  2013 BASIC_README
-rwxrwxr-x 1 root staff     47860 Aug 24  2013 genezi
-rwxrwxr-x 1 root staff  53865194 Aug 24  2013 libclntsh.so.11.1
-r-xr-xr-x 1 root staff   7996693 Aug 24  2013 libnnz11.so
-rwxrwxr-x 1 root staff   1973074 Aug 24  2013 libocci.so.11.1
-rwxrwxr-x 1 root staff 118738042 Aug 24  2013 libociei.so
-r-xr-xr-x 1 root staff    164942 Aug 24  2013 libocijdbc11.so
-r--r--r-- 1 root staff   2091135 Aug 24  2013 ojdbc5.jar
-r--r--r-- 1 root staff   2739616 Aug 24  2013 ojdbc6.jar
drwxrwsr-x 4 root staff      4096 Aug 24  2013 sdk
-rwxrwxr-x 1 root staff    192365 Aug 24  2013 uidrvci
-rw-rw-r-- 1 root staff     66779 Aug 24  2013 xstreams.jar
# ln -s libclntsh.so.11.1 libclntsh.so

D’apres le site de PECL, nous devons installer la version 1.4.x d’oci8 si on utilise PHP5 . Nous utiliserons le paramètre :

instantclient,/usr/local/lib/instantclient_11_2
# pecl install oci8-1.4.10
downloading oci8-1.4.10.tgz ...
Starting to download oci8-1.4.10.tgz (169,248 bytes)
.....done: 169,248 bytes
10 source files, building
running: phpize
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226
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] : instantclient,/usr/local/lib/instantclient_11_2
building in /tmp/pear/temp/pear-build-rootutoK4c/oci8-1.4.10
running: /tmp/pear/temp/oci8/configure --with-oci8=instantclient,/usr/local/lib/instantclient_11_2
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
[...]
Build complete.
Don't forget to run 'make test'.

running: make INSTALL_ROOT="/tmp/pear/temp/pear-build-rootutoK4c/install-oci8-1.4.10" install
Installing shared extensions:     /tmp/pear/temp/pear-build-rootutoK4c/install-oci8-1.4.10/usr/lib/php5/20131226/
running: find "/tmp/pear/temp/pear-build-rootutoK4c/install-oci8-1.4.10" | xargs ls -dils
262997   4 drwxr-xr-x 3 root root   4096 Nov 22 16:39 /tmp/pear/temp/pear-build-rootutoK4c/install-oci8-1.4.10
263027   4 drwxr-xr-x 3 root root   4096 Nov 22 16:39 /tmp/pear/temp/pear-build-rootutoK4c/install-oci8-1.4.10/usr
263028   4 drwxr-xr-x 3 root root   4096 Nov 22 16:39 /tmp/pear/temp/pear-build-rootutoK4c/install-oci8-1.4.10/usr/lib
263029   4 drwxr-xr-x 3 root root   4096 Nov 22 16:39 /tmp/pear/temp/pear-build-rootutoK4c/install-oci8-1.4.10/usr/lib/php5
263030   4 drwxr-xr-x 2 root root   4096 Nov 22 16:39 /tmp/pear/temp/pear-build-rootutoK4c/install-oci8-1.4.10/usr/lib/php5/20131226
263026 504 -rwxr-xr-x 1 root root 512928 Nov 22 16:39 /tmp/pear/temp/pear-build-rootutoK4c/install-oci8-1.4.10/usr/lib/php5/20131226/oci8.so

Build process completed successfully
Installing '/usr/lib/php5/20131226/oci8.so'
install ok: channel://pecl.php.net/oci8-1.4.10
configuration option "php_ini" is not set to php.ini location
You should add "extension=oci8.so" to php.ini

Nous pouvons activer l’extension dans PHP5 :

echo "extension=oci8.so"  > /etc/php5/mods-available/oci8.ini
php5enmod oci8
service apache2 restart

Verifions que c’est activé dans php5 :

# php5 -i | grep oci8
/etc/php5/cli/conf.d/20-oci8.ini,
oci8
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

Laisser un commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:

Logo WordPress.com

Vous commentez à l'aide de votre compte WordPress.com. Déconnexion / Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion / Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion / Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion / Changer )

Connexion à %s