Home >Backend Development >PHP Tutorial >Install oracle client and configure php5.3 under Linux, oraclephp5.3_PHP tutorial
Since the project requires the Oracle client compilation of php5.3 under Linux, I would like to briefly introduce the steps and detours taken.
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 according to the version of the operating system. What I need is X86_64 selection
Instant Client for Linux x86-64
The files that need to be downloaded for 1.2 are as follows:
One thing that needs to be emphasized is that you need to register an oracle account to download normally.
2. Install the Oracle client package.
Upload the program package to the specified directory on the server
3. Install the OCI8 php extension (the installation path of php specified here is /usr/local/webserver/php)
It should be emphasized that when making, an error will be reported, showing that various library files cannot be found. The makefile needs to be modified to add the runtime address of oralce
Open the makefile and look for INCLUDE in the following form:
INCLUDES = -I/usr/local/php/include/php -I/usr/include/oracle/10.2.0.3/client
Then add =="-I/usr/lib/oracle/11.1/client64 at the end, and then make again and it will succeed.
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/":
5. Restart apache to allow OCI to take effect
6. Create the phpinfo.php file in the web directory, enter the content in it, and access it through the web
If you find the OCI8 part, it means that the OCI installation is normal, as shown in the picture below
Next, you can access the Oracle database through PHP. What you need to pay attention to is the Oracle connection string under PHP
Install rpm as root user -ivh oracle-instantclient-basic-11.1.0.1-1.x86_64.rpmrpm -ivh oracle-instantclient-sqlplus-11.1.0.1-1.x86_64.rpm 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 After setting the environment variables, you need to restart the machine! Create the configuration file. Create the following directory network/admin in the ORACLE_HOME directory, and create the file tnsnames.ora with the following content: 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 to the ORACLE_HOME/bin directory and execute the command: [yleesun@centos bin]$ ./sqlplus zxd/zxd@111Copyright (c) 1982, 2011, 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!
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
vim /etc/profile add
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
After setting the environment variables, you need to restart the machine!
Create configuration file
Create the following directory network/admin in the ORACLE_HOME directory, and create the file tnsnames.ora with the following content:
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
to ORACLE_HOME /bin directory, execute the command:
[yleesun@centos bin]$ ./sqlplus zxd/zxd@111
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
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:
It means the environment variable does not take effect!