search
HomeBackend DevelopmentPHP TutorialInstall oracle client and configure php5.3 under Linux, oraclephp5.3_PHP tutorial

Install oracle client under Linux and configure php5.3, oraclephp5.3

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:

Copy code 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

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

Copy code The code is as follows:

chmod +x *.rpm
#Give execution permissions 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 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 dynamic link library

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

Copy code The code is as follows:

yum install libaio
#yum installs the libaio library. libaio is an asynchronous non-blocking interface under Linux. It provides a way to read and write files in an asynchronous non-blocking way, and the reading and writing efficiency is relatively high
wget http://pecl.php.net/get/oci8-1.4.10.tgz
#DownloadOCIExtension
tar zxvf oci8-1.4.10.tgz
#unzip
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 compilation environment of the PHP plug-in module. The makefile required for compilation will be generated according to the specified environment variables. phpize is the content of php-devel, so under centos, just 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, install

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/":

Copy code The code is as follows:

extension = "oci8.so"

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

Copy code The code is as follows:

phpinfo();
?>

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

Copy code The code is as follows:

$username='***';
$passwd='***';
$protocol='TCP';
$SERVICE_NAME='***';
$ORACLE_SERVER_IP_ADDRESS='***.***.***.***';
$Port='1521′;
$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 Oracle client under linux

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!

How to install Oracle client under 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
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!

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/892259.htmlTechArticleInstall the oracle client under Linux and configure php5.3, oraclephp5.3 because the project requires php5 under Linux. 3 oracle client compilation, briefly introduce the steps and detours taken. 1. Download O...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

How to make PHP applications fasterHow to make PHP applications fasterMay 12, 2025 am 12:12 AM

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

PHP Performance Optimization Checklist: Improve Speed NowPHP Performance Optimization Checklist: Improve Speed NowMay 12, 2025 am 12:07 AM

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

PHP Dependency Injection: Improve Code TestabilityPHP Dependency Injection: Improve Code TestabilityMay 12, 2025 am 12:03 AM

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

PHP Performance Optimization: Database Query OptimizationPHP Performance Optimization: Database Query OptimizationMay 12, 2025 am 12:02 AM

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.