Install the oracle client in Linux and configure php5.3 and oraclephp5.3 _ PHP Tutorial

Source: Internet
Author: User
Install the oracle client in Linux and configure php5.3 and oraclephp5.3. Install the oracle client in Linux and configure php5.3. oraclephp5.3 compiles the oracle client in linux for the project. this section briefly introduces the steps and detours. 1. download the oracle client installed in O Linux and configure php5.3 and oraclephp5.3.

As the project needs to compile the oracle client of php5.3 in linux, this section briefly introduces 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;
}
?>


How to install the Oracle client in linux

Install rpm-ivh oracle-instantclient-basic-11.1.0.1-1.x86_64.rpmrpm-ivh oracle-instantclient-sqlplus-11.1.0.1-1.x86_64.rpm with root user configure vim/etc/profile add export ORACLE_HOME =/usr/lib/oracle/11.1.0.1/client64export ORACLE_BASE =/usr/lib/oracle/ 11.1.0.1export LD_LIBRARY_PATH = $ ORACLE_HOME/lib: $ LD_LIBRARY_PATHexport NLS_LANG = AMERICAN_AMERICA.AL32UTF8! Create a configuration file create the following directory network/admin under the ORACLE_HOME directory and create the file tnsnames. ora. the content is as follows: vim/usr/lib/oracle/11.1.0.1/client64/network/admin/tnsnames. ora # tnsnames. ora Network Configuration File:/opt/oracle10g/u01/network/admin/tnsnames. ora # Generated by Oracle configuration tools.111 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.15.111) (PORT = 1521 ))) (CONNECT_DATA = (SERVICE_NAME = dmsdb)) In the ORACLE_HOME/bin directory, run the command: [yleesun @ centos bin] $. /sqlplus zxd/zxd @ 111 Copyright (c) 1982,201 1, Oracle. all rights reserved. connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0-64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> test successful! Note: if the following error occurs: sqlplus: error while loading shared libraries: libsqlplus. so: cannot open shared object file: No such file or directory, the environment variable does not take effect!

How to install the Oracle client in linux

Install as root user
Rpm-ivh oracle-instantclient-basic-11.1.0.1-1.x86_64.rpm
Rpm-ivh oracle-instantclient-sqlplus-11.1.0.1-1.x86_64.rpm configuration
Add vim/etc/profile
Export ORACLE_HOME =/usr/lib/oracle/11.1.0.1/client64
Export ORACLE_BASE =/usr/lib/oracle/11.1.0.1
Export LD_LIBRARY_PATH = $ ORACLE_HOME/lib: $ LD_LIBRARY_PATH
Export NLS_LANG = AMERICAN_AMERICA.AL32UTF8
To set environment variables, restart the machine!
Create a configuration file
Create the following network/admin directory in the ORACLE_HOME directory and create the tnsnames. ora file. the content is as follows:
Vim/usr/lib/oracle/11.1.0.1/client64/network/admin/tnsnames. ora
# Tnsnames. ora Network Configuration File:/opt/oracle10g/u01/network/admin/tnsnames. ora
# Generated by Oracle configuration tools.111 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.15.111) (PORT = 1521 )))
(CONNECT_DATA =
(SERVICE_NAME = dmsdb) test
Go to the ORACLE_HOME/bin directory and run the following command:
[Yleesun @ centos bin] $./sqlplus zxd/zxd @ 111
Copyright (c) 1982,201 1, Oracle. All rights reserved.
Connected:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0-64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL test successful! Note:
If the following error occurs:
The environment variable does not take effect!

Because the project needs to compile the oracle client of php5.3 in linux, this article briefly introduces the steps and detours. 1. download O...

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.