PHP Install Oracle Extensions (OIC8 installation tutorial)

Source: Internet
Author: User
Tags php server php and zip zend oracle database

This article mainly describes the PHP environment and the Oracle database is not on the same server, the installation of PHP environment compiled

According to official documentation http://cn2.php.net/manual/zh/oci8.installation.php
PHP to compile the time to add this parameter –with-oci8, but add this parameter has a prerequisite, is that the corresponding library file must be installed.

There are two ways to install a library file:

Your PHP environment and Oracle on the same server (usually Oracle is very large, this method is not appropriate)
Two. Install Oracle Instant Client libraries on your PHP server. (This method is suitable for PHP and Oracle not on a server)

Installation steps for Oracle Instant Client libraries: see here
1. Download the appropriate instant Client packages installation package for your own system. Where the installation package requires Basic or basic lite packages (select a system platform based on this link and download the corresponding Basic or SDK and so on)

Here I downloaded three zip packages, respectively:

The code is as follows Copy Code
Instant Client Package–basic
Instant Client Package–sql*plus
Instant Client PACKAGE–SDK

2. Unzip the package to a separate directory, such as "instantclient". (I put the three packages together and put them in/usr/local/instantclient)

3. Set the load path of the library in the environment variable, the path to the second set path "Instantclient". Most UNIX platform environment variables are set Ld_library_path, and Windows systems should use PATH

4. You can start your application.

Loading library (3rd step above, environment variable)
The library mentioned above needs to be loaded into the Linux system, so how do you load it?
Method One:
Edit/etc/ld.so.conf, add a line of library file path/usr/local/instantclient (depending on the actual situation)
Note: CentOS's/etc/ld.so.conf file contains all the/etc/ld.so.conf.d/*.conf files loaded with include, so we can create a file/etc/ld.so.conf.d/ oracle.conf, add a line of library file path/usr/local/instantclient (depending on the actual situation), rather than directly edit the/etc/ld.so.conf file.

Method Two:

Setting up Linux system settings environment variables

The code is as follows Copy Code
Vim ~/.BASHRC

Last line Join

The code is as follows Copy Code


Export Ld_library_path= $LD _library_path:/usr/local/instantclient

This is modified according to the actual situation, as the instantclient position of the second step is placed in the/usr/local/instantclient

Compiling PHP
If you are compiling and installing PHP, you need to add the –with-oci8 parameter, because I put instant Client packages in the/usr/local/instantclient
So the –with-oci8 parameter can be written like this

The code is as follows Copy Code

–with-oci8=shared,instantclient,/usr/local/instantclient

The PHP instance compiles as follows:

The code is as follows Copy Code

./configure--prefix=/usr/local/php-5.3--with-config-file-path=/usr/local/php-5.3/etc-- WITH-CONFIG-FILE-SCAN-DIR=/USR/LOCAL/PHP-5.3/ETC/PHP.D--with-mysql=/usr/local/mysql--with-mysqli=/usr/local/ Mysql/bin/mysql_config--with-iconv--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib =/USR--enable-xml--disable-rpath--enable-bcmath--enable-shmop--enable-sysvsem-- With-curl--with-curlwrappers--enable-mbregex--enable-fpm--enable-mbstring--with-mcrypt-- Enable-gd-native-ttf--with-mhash--enable-pcntl--enable-sockets--with-xmlrpc--with-openssl-- Enable-safe-mode--enable-zip--with-oci8=shared,instantclient,/usr/local/instantclient

PHP Official example, this is written./configure–with-oci8=shared,instantclient,/usr/lib/oracle//client/lib
If you can't find libclntsh.so at compile time, you can add a soft chain

The code is as follows Copy Code

Ln-s/usr/local/instantclient/libclntsh.so.12.1/usr/local/instantclient/libclntsh.so

Installation Oci8 Expansion

Use PHP for PECL installation expansion

The code is as follows Copy Code
./pecl Install Oci8

In the prompt input, Instant Client Packages Library Path when input the actual path, here input:

The code is as follows Copy Code

Shared, Instantclient,/usr/local/instantclient
 

[root@localhost bin]#./pecl Install oci8
Downloading Oci8-2.0.8.tgz ...
Starting to download oci8-2.0.8.tgz (190,854 bytes)
....... ... done:190,854................... ... Bytes
One source files, building
warning:php_bin/usr/local/php-5.3/bin/php appears to have a suffix-5.3/bin/php, But config variable php_suffix does not match
Running:phpize
configuring for:
PHP Api VERSION:  &N bsp;      20090626
Zend Module Api no:      20090626
Zend Extension Api no:   220090626
Please provide the path to the Oracle_home directory. Use ' instantclient,/path/to/instant/client/lib ' if your ' re compiling with Oracle instant client [AutoDetect]: Shared,inst Antclient,/usr/local/instantclient

Finally, add Oci8 to php.ini.

The code is as follows Copy Code

Extension=oci8.so

View Phpinfo

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.