Oracle Client Extension (OCI8) installation tutorial under PHP _php instance

Source: Internet
Author: User
Tags sqlplus

Recent projects need to use PHP to access Oracle databases and have to install Oci8 extensions to PHP under Linux. PHP can also use PDO to access Oracle databases, but you still need to install clients.

First to the Oracle official website of this page to download the relevant files, note to the database server version, must correspond, otherwise the installation will not even succeed, but also to distinguish 32-bit, 64-bit server, For example, I want to connect the database server is the ORACLE10.2.0.4,64 bit host, then I want to download the following three files:

Copy Code code 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. Install with the following command

Copy Code code 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 OCI8 PHP Extension

Copy Code code as follows:

# yum Install Libaio
# CD ~
# wget Http://pecl.php.net/get/oci8-1.3.5.tgz

3. Then execute the order

Copy Code code 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 a few more times until the following prompts appear)

[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 are ever happen to want to link against installed libraries
in a given directory, Libdir, your must either use Li Btool, and
Specify the full pathname to the library, or use the '-llibdir '
flag during linking and doing 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
     Duri ng linking
  -use the '-WL,--RPATH-WL,LIBDIR ' linker flag
  -Have your system Administrat or add Libdir to '/etc/ld.so.conf '

Operating system documentation about shared libraries for
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 ext Directory

Copy Code code as follows:

# mkdir ext/

Copy the oci8.so file to the php.ini ext directory
Copy Code code as follows:
# cp/root/oci8-1.3.5/modules/oci8.so/usr/local/php5/lib/ext/

5. Add extension=oci8.so inside the php.ini

As follows:

Copy Code code 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:

Copy Code code as follows:

/usr/local/apache2/bin/apachectl stop
/usr/local/apache2/bin/apachectl start

Refresh the test page. Found Oci8 appeared, it was done.

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.