PDO OCI connects Oracle

Source: Internet
Author: User
Tags zts


    1. Environment

      Host Linux


[[Email protected]_1 ~]$ lsb_release-alsb Version:: Base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch: Graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarchdistributor ID:       redhatenterpriseserverdescription:red Hat Enterprise Linux Server release 6.4 (Santiago) Release:6.4codename: Santiago[[email protected]_1 ~]$ uname-alinux test_1.smartpay.com.cn 2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29 11:47:4 1 EST x86_64 x86_64 x86_64 gnu/linux

Uname-a sees the system as 64 bits.

PHP version

Php-5.5.15.tar.gz

Already source installed in/usr/local/php

Apache 2.X has the source installed and integrated PHP.


2. Required Software

Download from Oracle

Http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm

oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm

Instantclient-sdk-linux.x64-12.1.0.2.0.zip


3. Installation of Oracle three components

RPM-IVH oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm RPM-IVH Oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpmln-s/USR/LIB/ORACLE/12.1/CLIENT64/USR/LIB/ORACLE/12.1/ Clientln-s/usr/include/oracle/12.1/client64/usr/include/oracle/12.1/client Unzip instantclient-sdk-linux.x64-12.1.0.2.0.zipcp-fr/home/devtac/soft/instantclient_12_1/sdk/usr/include/

Modify Etc/profile

Vi/etc/profile Add export Oracle_home=/usr/lib/oracle/12.1/client64export to the last side of the file ld_library_path=/usr/lib/oracle/ 12.1/client64: $LD _library_pathexport nls_lang= "American_america. Al32utf8 "
Exit VI, execute, make changes effective immediately source/etc/profile


Ld_library_path,nls_lang has not yet found much use in this installation.


4 Installing PDO and OCI

4.1 Installing PDO

CD to PHP decompression directory

Php-5.5.15/ext/pdo_oci

/usr/local/php/bin/phpize will generate the Configure file./configure--with-oci8--with-php-config=/usr/local/php/bin/ Php-configmake#make times could not find oci.h file I then copied the/usr/include/sdk/include directory to the head file cp/usr/include/sdk/include/*.h/home/ Devtac/soft/php-5.5.15/ext/pdo_oci/make #成功make Install #成功 #make install after successful/usr/local/php/lib/php/extensions/ Generate-rwxr-xr-x in the no-debug-zts-20121212/directory. 1 root root 496655 August 17:46 opcache.so-rwxr-xr-x. 1 root root 128581 September 11:07 pdo_oci.so


Configuring PDO

Add in PHP.ini

Extension=/usr/local/php/lib/php/extensions/no-debug-zts-20121212/pdo_oci.so

Restart Apache

php-m | grep PDO checks whether the extension is successful, and the browser access info.php can also verify that the extension was successful

[[Email protected]_1 bin]#/usr/local/php/bin/php-m | grep pdopdopdo_oci

4.2 Installing OCI

Similar to PDO the following is the installation command, which does not detail the

cd/home/devtac/soft/php-5.5.15 CD ext CD oci8//usr/local/php/bin/phpize./configure--with-oci8--with-php-c Onfig=/usr/local/php/bin/php-config make do install cd/usr/local/php/lib/php/extensions/no-debug-zts-20121212/

Configure PHP.ini


Extension=/usr/local/php/lib/php/extensions/no-debug-zts-20121212/oci8.so

/usr/local/php/bin/php-m | grep oci/usr/local/apache/bin/apachectl Restart


5. Write a PHP test

<?php$db= "OCI:DBNAME=//114.114.218.106:1521/XXXXX;"; $dbname = "xxxx"; $dbpwd = "xxxxx"; $pdo =new PDO ($db, $dbname, $dbpwd); $sql = "SELECT * from table"; $result = $pdo->query ($ SQL), foreach ($result as $row) {echo $row [1]. "\ t";}? >





PDO OCI connects Oracle

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.