PHP connects to Oracle database under Linux, linuxoracle_PHP tutorial

WBOY
Release: 2016-07-13 10:20:33
Original
990 people have browsed it

PHP connects to Oracle database under Linux, linuxoracle

Installation steps:

1. Install 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

Place it in the /usr/packages/ directory

# rmp -ivh oracle-instantclient*

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

*Note: Download the corresponding database version

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

Add some content:

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

Execute command # ldconfig

3. Install oci8

Download the latest oci8 components

Download address: http://pecl.php.net/package/oci8

Download oci-2.0.8.tgz

Place it in the /usr/packages/ directory

# tar -xvzf oci-2.0.8.tgz

# cd oci-2.0.8

# /usr/local/php/bin/phpize (用phpize生成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

Copy after login

After success, you will be informed that oci8.so has been successfully placed in the following directory

4. Configure PHP to support OCI extension

Modify php configuration file

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

Append the following content after the extension item

extension=oci8.so

5. Restart the Apache service test

# apachectl restart

Use the probe function phpinfo() to check whether the extension is enabled. If the following picture appears, it means the extension is enabled

6. Test database connection

Write oracle.php in the site root directory

The code is as follows:

<&#63;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);
  }
&#63;>
Copy after login

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

Explanation: 192.168.1.131 is the server address, which directly points to the site and directory of the server Apache.

Display Connected Oracle Successd! indicates that the database connection is successful.

php cannot connect to the oracle database

Please explain the specific meaning of "not easy to use". It needs to be analyzed based on the specific situation. If it prompts that there is no such function, then you should use ocilogon to replace this function.

How to connect to remote ORACLE database with PHP?


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/866668.htmlTechArticlePHP connects to Oracle database under Linux, linuxoracle installation steps: 1. Install oracle-instantclient Download address: http:// www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html Next...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!