Linux PHP connection to the Oracle database, linuxoracle_PHP tutorial

Source: Internet
Author: User
In Linux, PHP connects to the Oracle database and linuxoracle. Linux PHP connection Oracle database, linuxoracle installation steps: A, install oracle-instantclient: www.oracle.comtechnetworktopicslinuxx86-64soft-092277.html Linux PHP connection Oracle database, linuxoracle

Installation steps:

1. install oracle-instantclient

: Http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

Download oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm

Download
Oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm

In the/usr/packages/Directory

# Rmp-ivh oracle-instantclient *

The/usr/lib/oracle/11.2/client/lib/directory is generated.

* Note: Download the corresponding database version

2. modify the/etc/ld. so. conf configuration file

Append the following content:

/Usr/lib/oracle/11.2/client/lib/

Run the command # ldconfig

3. install oci8

Download the latest oci8 component

: Http://pecl.php.net/package/oci8

Download oci-2.0.8.tgz

In the/usr/packages/Directory

# Tar-xvzf oci-2.0.8.tgz # cd oci-2.0.8 #/usr/local/php/bin/phpize (generate configure configuration file with phpize )#. /configure -- with-php-config =/usr/local/php/bin/php-config -- with-oci8 = shared, instantclient, /usr/lib/oracle/11.2/client/lib # make & make install

The oci8.so file is successfully stored in the following Directory.

4. configure PHP to support OCI extension

Modify the php configuration file

# Vi/usr/local/php/lib/php. ini file

Append the following content after the extension item

Extension = oci8.so

5. restart Apache to test the service.

# Apachectl restart

Use the probe function phpinfo () to check whether the extension is enabled. if so, the extension is enabled.

6. test database connection

Compile oracle. php in the site root directory

The code is as follows:

<?php  $conn = ocilogon('test','test','192.168.23.131:1521/dev');  if (!$conn)  {    $Error = oci_error();    print htmlentities($Error['message']);    exit;  }  else  {    echo "Connected Oracle Successd!"."
"; ocilogoff($conn); }?>

Enter http: // 192.168.1.131/oracle. php in the address bar of the browser.

Note: 192.168.1.131 is the server address and directly points to the Apache site and directory on the server.

Show Connected Oracle Successd! The database is successfully connected.


Php cannot connect to the oracle database

Please describe the specific meaning of "bad" and analyze it based on the actual situation. if this function is not prompted, you should use ocilogon to replace this function.

How does PHP connect to a remote ORACLE database?



Installation steps: 1. install oracle-instantclient: Under the http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html...

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.