linux Installation of OCI client and php installation of oci8 extension
oci client installation
- Download package
oracle-instantclient18.3-basic-18.3.0.0.0-1.x86_64.rpm
oracle-instantclient18.3-devel-18.3.0.0.0-1.x86_64.rpm
oracle-instantclient18.3-sqlplus-18.3.0.0.0-1.x86_64.rpm - Installation
$ yum install oracle-instantclient18.3-basic-18.3.0.0.0-1.x86_64.rpm $ yum install oracle-instantclient18.3-devel-18.3.0.0.0-1.x86_64.rpm $ yum install oracle-instantclient18.3-sqlplus-18.3.0.0.0-1.x86_64.rpm $ echo "/usr/lib/oracle/18.3/client64/lib/" > /etc/ld.so.conf.d/oracle_client.conf $ /sbin/ldconfig $ CFLAGS="-I/usr/include/oracle/18.3/client64" $ CXXFLAGS="-I/usr/include/oracle/18.3/client64/"
- Connect to database
$ /usr/lib/oracle/18.3/client64/bin/sqlplus64 usr/pwd@//host:port/sid SQL*Plus: Release 18.0.0.0.0 - Production on Fri Sep 21 20:16:22 2018 Version 18.3.0.0.0 Copyright (c) 1982, 2018, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production With the Partitioning, OLAP and Data Mining options SQL>
If you can use sqlplus to connect to Oracle, the installation is basically successful
Install oci8 extension
- Installation
$ wget http://pecl.php.net/get/oci8-2.0.10.tgz $ tar -xf oci8-2.0.10.tgz $ phpize $ ./configure --with-oci8=shared,instantclient,/usr/lib/oracle/18.3/client64/lib --with-php-config=/usr/local/php/bin/php-config $ make $ make test $ make install
- View installation
$ php -m
The display information includes oci8, indicating that the installation is successful
- Download package
Now, oci8.so will be generated in no-debug-non-zts-20131226/ of all versions of php in the system,
Add the following code in php.ini according to the specific path
[oci8] extension = "/usr/local/php-5.6.24/lib/php/extensions/no-debug-non-zts-20131226/oci8.so"
Now you can operate oracle in php file!