Linux under PHP enable Oracle Support (OCI8)

Source: Internet
Author: User
Tags install php zts

The common problem with PHP is: Compile PHP When you forget to add an extension, and then want to add extensions, but because after installing PHP and loaded with something like pear, do not want to remove the directory reload, then you need to add a module support, Linux OS can add extensions to PHP dynamically with Phpize. The following is an example of extension module oci8 (PHP connection to Oracle database needs to be extended support) to do a simple explanation.

1. Download the Oracle client package, which contains relevant files such as OCI, Occi, and Jdbc-oci1.1 According to the Linux system to select the corresponding software, my 32-bit system, so download the following files:

oracle-instantclient11.2-basic-11.2.0.3.0-1.i386.rpm

oracle-instantclient11.2-devel-11.2.0.3.0-1.i386.rpm

1.2:http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html (Oracle website download requires registered users)

2. Install the Oracle client and run the following command:

RPM-IVH oracle-instantclient11.2-basic-11.2.0.3.0.i386.rpm

RPM-IVH oracle-instantclient11.2-devel-11.2.0.3.0.i386.rpm

3. Installing the oci8 PHP extension

3.1 Downloads oci8-1.4.10.tgz

: http://pecl.php.net/get/oci8-1.4.10.tgz

3.2 Upload the download file to the Linux server and unzip it

Command: Tar zxvf oci8-1.4.10.tgz#解压

3.3 Go to extract Directory

command: cd oci8-1.4.10

3.4 using phpize to prepare the compiler environment for the PHP plug-in module, it is necessary to generate compile-time makefile,phpize according to the specified environment variables, which belongs to php-devel content. So just run the Yum install Php-devel under CentOS ( Note: /usr/local/php/bin/phpize for my PHP directory, the difference will need to change )

/usr/local/php/bin/phpize cflags= "-i/usr/lib/oracle/11.1/client" cxxflags= "-i/usr/lib/oracle/11.1/client"

3.5 Compiling, installing

have PHP compression packages that are exactly the same as existing PHP. I'm using a php-5.5.3.tar.gz. After expanding into the inside of the Ext/oci8 directory,

Then execute the command:/usr/local/php/bin/phpize #这是一个可执行的文本文件 to make sure it is in the system

Will find some configure files in the current directory,

If there is no error, run the command;

./configure--with-php-config=/usr/local/php/bin/php-config--with-oci8=/usr/lib/oracle/11.1/client

Be careful to make sure that/usr/local/php/bin/php-config exists first. If your PHP installation path is not the default, change it.

Run the following command again, and then it tells you a directory where you copy the oci8.so from the directory to the directory Extension_dir in your php.ini

Make
Make install

Need to emphasize is make when the error, display a variety of library files can not be found, need to modify the makefile file to join the Oralce runtime address

Open the makefile and look for the 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/client at the end and re-make will succeed.

4. Modify PHP.ini (/usr/local/php/etc/php.ini)

Add a line after Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/":

extension =" oci8.so "

Note: To make sure that there are oci8.so files in the/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/directory

5. Restart Apache for the OCI to take effect 6. Create a phpinfo.php file in the Web directory where you enter the content and access it through the Web

<?phpphpinfo ();? >

If the OCI8 section is found, the OCI is installed properly, as shown in


Description Oci8 installation is successful, then you can use PHP to access the Oracle database.











Linux under PHP enable Oracle Support (OCI8)

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.