Install the oracle client in Linux and configure php5.3

Source: Internet
Author: User
This article mainly introduces how to install the oracle client in Linux and configure php5.3. For more information about how to compile the oracle client in linux, briefly introduce the steps and detours.

1. download the Oracle client package, which contains related files such as OCI, OCCI and JDBC-OCI.

1.1 Download file address

Http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
Select the corresponding software based on the operating system version. what I need is X86_64.
Instant Client for Linux x86-64

1.2 The files to be downloaded are as follows:

The code is as follows:


Oracle-instantclient11.1-basic-11.1.0.7.0-1.x86_64.rpm
Oracle-instantclient11.1-devel-11.1.0.7.0-1.x86_64.rpm
Oracle-instantclient11.1-sqlplus-11.1.0.7.0-1.x86_64.rpm

It must be emphasized that an oracle account must be registered to download the data normally.

2. install the Oracle client package.

Upload the package to the specified directory on the server

The code is as follows:


Chmod + x *. rpm
# Grant the execution permission to the RPM Package
Rpm-ivh oracle-instantclient11.1-basic-11.1.0.7.0-1.x86_64.rpm oracle-instantclient11.1-devel-11.1.0.7.0-1.x86_64.rpm oracle-instantclient11.1-sqlplus-11.1.0.7.0-1.x86_64.rpm
# Install the RPM Package
Echo "/usr/lib/oracle/11.1/client64/lib/">/etc/ld. so. conf. d/oracle_client.conf
# Add the library path to the default load
/Sbin/ldconfig
# Reload the dynamic link library

3. install the php extension of OCI8 (the installation path of php is/usr/local/webserver/php)

The code is as follows:


Yum install libaio
# Install the libaio Library in yum. libaio is an asynchronous non-blocking interface in Linux. It provides an asynchronous non-blocking mode to read and write files, which is highly efficient.
Wget http://pecl.php.net/get/oci8-1.4.10.tgz
# Download OCI extensions
Tar zxvf oci8-1.4.10.tgz
# Decompress
Cd oci8-1.4.10
/Usr/local/webserver/php/bin/phpize CFLAGS = "-I/usr/lib/oracle/11.1/client64" CXXFLAGS = "-I/usr/lib/oracle/ 11.1/client64"
# Use phpize to prepare the compiling environment of the PHP plug-in module. makefile is generated based on the specified environment variables. phpize is the content of php-devel, therefore, in centos, you only need to run yum install php-devel to install it.
./Configure-with-php-config =/usr/local/webserver/php/bin/php-config-with-oci8 =/usr/lib/oracle/11.1/client64
Make
Make install
# Compile and install

It should be emphasized that an error will be reported during make, indicating that the library files cannot be found. you need to modify the makefile file and add it to the oralce runtime library address.
Open makefile and find INCLUDE in the following format:
Using des =-I/usr/local/php/include/php-I/usr/include/oracle/10.2.0.3/client
Add = "-I/usr/lib/oracle/11.1/client64 at the end, and then make again.

4. modify PHP. ini (/usr/local/webserver/php/etc/php. ini)

Add a line after extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613:

The code is as follows:


Extension = "oci8.so"

5. restart apache to make OCI take effect.

6. create the phpinfo. php file in the web Directory, enter the content, and access the file through the web.

The code is as follows:


<? Php
Phpinfo ();
?>

If the OCI8 part is found, the OCI installation is normal, as shown in

Next, you can access the oracle database through php. Note that the connection string of Oracle under php is

The code is as follows:


<? Php
$ Username = '***';
$ Passwd = '***';
$ Protocol = 'tcp ';
$ SERVICE_NAME = '***';
$ ORACLE_SERVER_IP_ADDRESS = '***.***.***.***';
$ Port = '000000 ′;
$ Db = "(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = $ protocol) (HOST = $ ORACLE_SERVER_IP_ADDRESS) (PORT = $ Port ))) (CONNECT_DATA = (SID = $ SERVICE_NAME )))";
$ Conn = oci_connect ($ username, $ passwd, $ db );
PutEnv ("NLS_LANG = SIMPLIFIED CHINESE_CHINA.AL32UTF8 ");
If (! $ Conn ){
$ E = oci_error ();
Print htmlentities ($ e ['message']);
Exit;
} Else {
Echo "connection to oracle successful! ";
Return $ conn;
}
?>

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.