Installation and configuration of PHP Oracle extended OCI8 under Linux system

Source: Internet
Author: User

Installation and configuration of PHP Oracle extended OCI8 under Linux system

Implementing a PHP program to access Oracle DB
Date: 2014.09.02
Write Liu Qunying (Qunyingliu)

    • environment description : Apache version, PHP version, Oracle DB version, Linux release version

    • RPM Package Installation Oracle-instantclient client

    • system environment and PHP configuration modification : LD.SO.CONF.D directory configuration file with extended field information in php.ini Modify

    • test the link code to confirm that the configuration was successful

    1. Environment Description :

    • Local System: CentOS Linux 6.4 x64

    • Apache 2.2.22:/usr/local/apache2

    • PHP 5.4:/usr/local/php

    • Oracle DB 11.2.0.4

RPM Package installs local Oracle client:

Download the following RPM packages from the Oracle Instant Client website:

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

oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm

oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm

oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm

Use the following command to install:

RPM-IVH oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm

RPM-IVH oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm

RPM-IVH oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm


Source code Compilation Install oci8 extension Download:

wget http://pecl.php.net/get/oci8-1.4.10.tgz

Decompression: TAR-ZXVF oci8-1.4.10.tgz

Installation:

CD oci8-1.4.10/usr/local/php/bin/phpize cflags= "-i/usr/lib/oracle/11.2.0.4.0/client64/" CXXFLAGS= "-I/usr/lib/ oracle/11.2.0.4.0/client64/"

./configure--with-php-config=/usr/local/php/bin/php-config--with-oci8=instantclient,/usr/lib/oracle/11.2.0.4.0 /client64/lib/

Make

Make instal

The path to the lphp path and Oracle client are subject to change based on the actual situation.


If a pecl program exists in the system, you can install the oci8 extension by using the following command:

PECL Install Oci8


System environment and PHP configuration modification Modify the system configuration:

echo "/usr/lib/oracle/11.2.0.4.0/client64//lib/"

>/etc/ld.so.conf.d/oracle_client.conf/sbin/ldconfig


To modify the php.ini configuration file:

Extension_dir = "/usr/local/php5/lib/ext"

Extension = "oci8.so"

Oci8.privileged_connect = On


Restart Apache to make the changes effective


/usr/local/apache2/bin/apachectl restart


Test the link code to confirm that the configuration was successful

<?php

$conn = Oci_connect (' Qunyingliu ', ' Testqunyingliu ', ' ORACLE.TEST.LOCALHOST/ORCL ');
Needs to be modified based on actual configuration information

$stid = Oci_parse ($conn, ' Select table_name from User_tables ');
Database operation statements can be modified according to actual requirements
Oci_execute ($stid);

echo "<table>\n";
while ($row = Oci_fetch_array ($stid, oci_assoc+oci_return_nulls)) = = False) {
echo "

\ n ";
foreach ($row as $item) {
echo "<td>". ($item!== null? htmlentities ($item, ent_quotes): ""). " \ n ";
}
echo "\ n";
}
echo "</table>\n";

?>

Related references:
http://php.net/manual/zh/function.oci-connect.php
http://php.net/manual/zh/book.oci8.php
Http://pecl.php.net/get/oci8-1.4.10.tgz
Http://pecl.php.net/package-changelog.php?package=oci8
Http://www.oracle.com/technetwork/cn/topics/linuxx86-64soft-092277.html


This article from "Ops said: from rookie to veteran" blog, please be sure to keep this source http://liuqunying.blog.51cto.com/3984207/1548023

Installation and configuration of PHP Oracle extended OCI8 under Linux system

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.