PHP Oracle client extension (OCI8) installation tutorial

Source: Internet
Author: User
This article mainly introduces the Oracle client extension (OCI8) installation tutorial in PHP, which is implemented in Linux. OCI8 is the PHP extension module used to connect to the Oracle database, if you need it, refer to the ORACLE installation tutorial.

Recently, the project needs to access the oracle database using php, and the oci8 extension has to be installed for php in linux. Php can also use pdo to access the oracle database, but you still need to install the client.

First, go to the oracle official website to download the relevant files. Be sure to connect to the database server version. Otherwise, the installation will fail, at the same time, we need to distinguish between 32-bit and 64-bit servers. for example, if the database server I want to connect to is oracle10.2.0.4 and 64-bit, I want to download the following three files:

The code is as follows:


Oracle-instantclient-basic-10.2.0.4-1.x86_64.rpm
Oracle-instantclient-devel-10.2.0.4-1.x86_64.rpm
Oracle-instantclient-sqlplus-10.2.0.4-1.x86_64.rpm

1. run the following command to install

The code is as follows:


# Rpm-ivh oracle-instantclient-basic-10.2.0.4-1.x86_64.rpm oracle-instantclient-devel-10.2.0.4-1.x86_64.rpm oracle-instantclient-sqlplus-10.2.0.4-1.x86_64.rpm

2. install the OCI8 PHP extension

The code is as follows:


# Yum install libaio
# Cd ~
# Wget http://pecl.php.net/get/oci8-1.3.5.tgz

3. then execute the command

The code is as follows:


# Tar zxvf oci8-1.3.5.tgz
# Cd oci8-1.3.5/
#/Usr/local/php5/bin/phpize CFLAGS =/usr/lib/oracle/11.2/client64/CXXFLAGS =/usr/lib/oracle/11.2/client64/
#. /Configure -- with-php-config =/usr/local/php5/bin/php-config -- with-oci8 = instantclient,/usr/lib/oracle/11.2/client64/lib/
# Make
# Make install (run multiple times here until the following prompt appears)

[Root @ webserver02 oci8-1.3.5] # make install
/Bin/sh/root/oci8-1.3.5/libtool -- mode = install cp./oci8.la/root/oci8-1.3.5/modules
Cp./. libs/oci8.so/root/oci8-1.3.5/modules/oci8.so
Cp./. libs/oci8.lai/root/oci8-1.3.5/modules/oci8.la
PATH = "$ PATH:/sbin" ldconfig-n/root/oci8-1.3.5/modules
----------------------------------------------------------------------
Libraries have been installed in:
/Root/oci8-1.3.5/modules

If you ever happen to want to link against installed libraries
In a given directory, LIBDIR, you must either use libtool, and
Specify the full pathname of the library, or use the '-llibdir'
Flag during linking and do at least one of the following:
-Add LIBDIR to the 'ld _ LIBRARY_PATH 'environment variable
During execution
-Add LIBDIR to the 'ld _ RUN_PATH 'environment variable
During linking
-Use the '-Wl, -- rpath-Wl, libdir' linker flag
-Have your system administrator add LIBDIR to '/etc/ld. so. Conf'

See any operating system documentation about shared libraries
More information, such as the ld (1) and ld. so (8) manual pages.
----------------------------------------------------------------------
Installing shared extensions:/usr/local/php5/lib/php/extensions/no-debug-zts-20090626/
# Cd/usr/local/php5/lib

4. create the ext Directory

The code is as follows:


# Mkdir ext/


Copy the oci8.so file to the ext directory of php. ini.

The code is as follows:

# Cp/root/oci8-1.3.5/modules/oci8.so/usr/local/php5/lib/ext/

5. add extension = oci8.so to php. ini.

As follows:

The code is as follows:


Extension_dir = "/usr/local/php5/lib/ext"
Extension = "oci8.so"
Session. save_path = "/tmp/php"
Oci8.privileged _ connect = on

Restart the apache service:

The code is as follows:


/Usr/local/apache2/bin/apachectl stop
/Usr/local/apache2/bin/apachectl start

Refresh the test page. If oci8.

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.