Remotely connect to Oracle using PHP in Linux

Source: Internet
Author: User

The OCI package is required for PHP to remotely connect to Oracle. This package is provided by oracle. You can directly install the Oracle InstantClient to obtain this package.
Http://www.oracle.com/technology/tech/oci/instantclient/instantclient.html

Easy to install
Rpm-Uvh oracle-instantclient-basic-10.2.0.3-1.i386.rpm
Rpm-Uvh oracle-instantclient-devel-10.2.0.3-1.i386.rpm

After the installation is complete, you can view the installed library file in/usr/lib/oracle.

After the need to re-compile php, coupled with -- with-oci8 = share, instantclient,/usr/lib/oracle/10.2.0.3/client/lib parameters, as follows:
./Configure -- with-mysql -- with-apxs2 =/usr/local/apache2/bin/apxs -- with-oci8 = share, instantclient,/usr/lib/oracle/10.2.0.3/client/lib

Test code:

<? Php
$ Conn = OCILogon ('username', 'Password', '192. 168.1.2/test ');
If (! $ Conn ){
$ E = oci_error ();
Print htmlentities ($ e ['message']);
Exit;
}
Else
{
Echo "Successfully connected to Oracle! \ N ";
Ocilogoff ($ conn );
}
?>

Related links:
Http://www.oracle.com/technology/pub/notes/technote_php_instant.html

There is also the oci compilation parameters in php. You can see the README of ext/oci8 in the php original code Directory, which has an explanation.

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.