- First Install Apache and PHP
- Configuring PHP with OCI8
apt-get install php5-mysql apache2 libapache2-mod-php5 php-pear unzip libaio1
- Then download 2 packages from Oracle:
Oracle Instant Client Downloads for Linux x86-64
Instant Client Package - Basic Lite: Smaller version of the Basic package, with only English error messages and Unicode, ASCII, and Western European character set support
Download instantclient-basiclite-linux.x64-12.1.0.2.0.zip (31,302,454 bytes) (cksum - 3592144768)
Instant Client Package - SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client
Download instantclient-sdk-linux.x64-12.1.0.2.0.zip (667,174 bytes) (cksum - 1047596065)
- Upload these 2 packages to server, uncompress them put it under same folder:
unzip instantclient-basiclite-linux.x64-12.1.0.2.0.zip
unzip instantclient-sdk-linux.x64-12.1.0.2.0.zip
mkdir -p /usr/lib/oracle/12.1/client64/lib
mv instantclient_12_1/* /usr/lib/oracle/12.1/client64/lib/
Link libclntsh.so.12.1 libclntsh.so
cd /usr/lib/oracle/12.1/client64/lib/
ln -s libclntsh.so.12.1 libclntsh.so
Make sure the sdk/ folder and files also under same directory:
ls -alt /usr/lib/oracle/12.1/client64/lib/
lrwxrwxrwx 1 root root 17 Mar 9 11:43 libclntsh.so -> libclntsh.so.12.1
drwxr-xr-x 3 root root 4096 Mar 9 11:33 ..
drwxrwxr-x 5 root root 4096 Jul 7 2014 sdk
-rwxrwxr-x 1 root root 6990875 Jul 7 2014 libclntshcore.so.12.1
-rwxrwxr-x 1 root root 58793741 Jul 7 2014 libclntsh.so.12.1
-r-xr-xr-x 1 root root 1768370 Jul 7 2014 libipc1.so
-r-xr-xr-x 1 root root 544150 Jul 7 2014 libmql1.so
-rwxrwxr-x 1 root root 2576030 Jul 7 2014 libocci.so.12.1
-r-xr-xr-x 1 root root 156353 Jul 7 2014 libocijdbc12.so
-r--r--r-- 1 root root 3692096 Jul 7 2014 ojdbc6.jar
-r--r--r-- 1 root root 3698857 Jul 7 2014 ojdbc7.jar
-rw-rw-r-- 1 root root 71202 Jul 7 2014 xstreams.jar
-rwxrwxr-x 1 root root 29404 Jul 7 2014 adrci
-rw-rw-r-- 1 root root 450 Jul 7 2014 BASIC_LITE_README
-rwxrwxr-x 1 root root 43944 Jul 7 2014 genezi
-r-xr-xr-x 1 root root 6213011 Jul 7 2014 libnnz12.so
-rwxrwxr-x 1 root root 6005681 Jul 7 2014 libociicus.so
-r-xr-xr-x 1 root root 337137 Jul 7 2014 libons.so
-rwxrwxr-x 1 root root 118491 Jul 7 2014 liboramysql12.so
-rwxrwxr-x 1 root root 227410 Jul 7 2014 uidrvci
Optional add it into LD_LIBRARY by create file: /etc/ld.so.conf.d/x86_64-oracle.conf
# Oracle Instant Client
/usr/lib/oracle/12.1/client64/lib
run ldconfig to apply the changes.
# ldconfig
- Installing OCI8 from PECL
http://pecl.php.net/package/oci8
Use the OCI8 extension to access Oracle Database. PHP OCI8 2.1 builds with PHP 7.
Use 'pecl install oci8-2.0.10' to install OCI8 for PHP 5.2 - PHP 5.6.
Use 'pecl install oci8-1.4.10' to install PHP OCI8 1.4 for PHP 4.3.9 - PHP 5.1.
Debian Jessi comes with PHP 5.6, when it ask the path for library give it the directory where the library located:
# pecl install oci8-2.0.10
downloading oci8-2.0.10.tgz ...
Starting to download oci8-2.0.10.tgz (Unknown size)
.....done
running: phpize
Configuring for:
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/lib/oracle/12.1/client64/lib
Build process completed successfully
Installing '/usr/lib/php5/20131226/oci8.so'
install ok: channel://pecl.php.net/oci8-2.0.10
configuration option "php_ini" is not set to php.ini location
You should add "extension=oci8.so" to php.ini
Create oci8.ini file for php: /etc/php5/mods-available/oci8.ini
extension=oci8.so
cd /etc/php5/cli/conf.d/
ln -s ../../mods-available/oci8.ini
cd /etc/php5/apache2/conf.d/
ln -s ../../mods-available/oci8.ini
service apache2 restart
References:
http://php.net/manual/en/oci8.installation.php
http://www.oracle.com/technetwork/articles/technote-php-instant-084410.html
In case you got error message when start Apache:
# cat error.log
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20131226/oci8.so' - libaio.so.1: cannot open shared object file: No such file or directory in Unknown on line 0
[Mon Oct 17 16:06:28.407599 2016] [mpm_prefork:notice] [pid 21276] AH00163: Apache/2.4.10 (Debian) configured -- resuming normal operations
[Mon Oct 17 16:06:28.407640 2016] [core:notice] [pid 21276] AH00094: Command line: '/usr/sbin/apache2'
Make sure the oci8.so file exist:
# ls /usr/lib/php5/20131226/oci8.so
And Install the Libaio:
# apt-get install libaio1
No comments:
Post a Comment