Install the oracle client in 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:
Copy codeThe 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
Copy codeThe 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)
Copy codeThe 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:
Copy codeThe 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.
Copy codeThe 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
Copy codeThe 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!