System: Linux Centos 7.0
In order for PHP to operate Oracle database, it is absolutely necessary to install the Oracle extension. The Oracle extension of php is called oci
Oracle Extension Pack Download Address:
The following download list will be displayed on the webpage:
Download Oracle Database 10g Instant Client for Microsoft Windows (32-bit)
Download Oracle Database 10g Instant Client for Microsoft Windows 64-bit Itanium
Download Oracle Database 10g Instant Client for Microsoft Windows (x64)
Download Oracle Database 10g Instant Client for Linux x86
Download Oracle Database 10g Instant Client for Linux x86-64
Download Oracle Database 10g Instant Client for Linux Itanium …
If the system is 32 bits, select the 4th and 64 bits select the 5th.
The wrong choice will cause the compatibility failure of makephpci8.
The following is a demonstration of a 64-bit system.
Step 1: Install oracle
rpm -ivh oracle-instantclient12.1-basic-22.214.171.124.0-1.x86_64.rpm rpm -ivh oracle-instantclient12.1-devel-126.96.36.199.0-1.x86_64.rpm rpm -ivh oracle-instantclient12.1-sqlplus-188.8.131.52.0-1.x86_64.rpm
Note: oracle package version should be compatible with oci8 package version. The reference text given by php website is
Use the OCI8 extension to access Oracle Database. The extension can be
linked with Oracle client libraries from Oracle Database 10.2, 11, or
12.1. These libraries are found in the database installation, or in the free Oracle Instant Client available from Oracle. Oracle’s
standard cross-version connectivity applies. For example, PHP OCI8
linked with Instant Client 11.2 can connect to Oracle Database 9.2
onward. See Oracle’s note “Oracle Client / Server Interoperability
Support” (ID 207303.1) for details. PHP OCI8 2.0 can be built with PHP
5.2 onward. Use the older PHP OCI8 1.4.10 when using PHP 4.3.9 through to PHP 5.1.x, or when only Oracle Database 9.2 client libraries are
The official website means that when installing oci8, it is necessary to ensure that oracle extensions +oci8+php versions are agreed upon, otherwise there will be problems. -English is not good, that’s probably what it means.
Step 2: Download php oci Extensions
Install oci8 extension download address:http://pecl.php.net/package/oci8
My php version is 5.5.4. According to the description on the website, I chose oci8-2.0.0.tgz package.
tar zxvf oci8-2.0.0.tgz cd oci8-2.0.0.tgz /usr/bin/phpize ./configure --with-php-config=/usr/bin/php-config --with-oci8=shared,instantclient,/usr/lib/oracle/11.2/client/lib make make install
1.oci8-2.0.0.tgz This is a separate extension package. You can also download the complete php installation package, such as php-5.5.28.tar.gz. After decompression, cd to the oci8 directory under ext directory.
2.phpize and php-config are not necessarily in the above path, because the method of installing lamp environment is different for everyone, you can use which command to find them, such as which phpize.
3. The key point is to ensure that phpize, php-config, and oracle are installed correctly.
Step 3: configure php.ini
In fact, the third step is not required most of the time, and the system will add the extension by default.
You can use the find command to find this file, find a configuration item similar to extension = “”and add a line of extension = “oci8.so “description: after make and makeinstall in the second step, an oci8.so file will be generated. you can use the find command to find the path. Extension = “oci8.so” to combine the configuration item extension _ dir = “/usr/lib/php/modules”, the meaning of these two sentences is to find oci8.so extension under /usr/lib/php/modules, in other words, if your oci8 extension is not generated under/usr/lib/PHP/modules directory, then you need to change extension _ dir to ensure that the path of oci8.so is correct
After the above steps are completed, restart the proxy service. PHPINFO () check it out. Has it succeeded? !