Linux _php instance of PHP connection Oracle database

Source: Internet
Author: User

Installation steps:

I. Installation of oracle-instantclient

Download Address: 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

Put it in the/usr/packages/directory.

# RMP-IVH oracle-instantclient*

The/usr/lib/oracle/11.2/client/lib/directory is generated at this time

* Note: Download the corresponding database version

Ii. Modify the/etc/ld.so.conf configuration file

Append content:

/usr/lib/oracle/11.2/client/lib/

Execute Command # Ldconfig

Iii. installation of Oci8

Download the latest OCI8 components

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

Download oci-2.0.8.tgz

Put it in the/usr/packages/directory.

# TAR-XVZF oci-2.0.8.tgz

# cd oci-2.0.8 #

/usr/local/php/bin/phpize (phpize configuration file is generated with configure)

#./ Configure--with-php-config=/usr/local/php/bin/php-config--WITH-OCI8=SHARED,INSTANTCLIENT,/USR/LIB/ORACLE/11.2/ Client/lib

# make && make install

Success will tell you that oci8.so has been successfully placed in the following directory

Iv. Configuring PHP Support OCI Extensions

Modify PHP configuration file

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

Append the following after the extension item

Extension=oci8.so

Restart the Apache service test

# apachectl Restart

Use the probe function phpinfo () to see if the extension is open, if the following illustration shows that the extension opens

VI. Testing Database connections

Writing 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!".) <br> ";
    Ocilogoff ($conn);
>

Browser address bar Input http://192.168.1.131/oracle.php

Description: 192.168.1.131 is the server address, direct point to the server Apache site and directory.

Display Connected Oracle successd! indicates a successful database connection.

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.