Home php教程 php手册 Windows2003 + PHP5.4.7 + Apache2.2.15 + Oracle9.0

Windows2003 + PHP5.4.7 + Apache2.2.15 + Oracle9.0

Jun 06, 2016 pm 07:57 PM

Oracle数据库与Web服务器分布在两台机器上。 Web端的配置: 下载 oracle instant client:instantclient_10_2,存放路径:D:\oracle_instantclient\instantclient_10_2 Windows 的系统 Path 变量前加:D:\oracle_instantclient\instantclient_10_2 路径。 ph

    Oracle数据库与Web服务器分布在两台机器上。

    Web端的配置:

    下载 oracle instant client:instantclient_10_2,存放路径:D:\oracle_instantclient\instantclient_10_2
    Windows 的系统 Path 变量前加:D:\oracle_instantclient\instantclient_10_2 路径。
    php.ini 中打开 oci 开关:
     extension=php_oci8.dll      ; Use with Oracle 10gR2 Instant Client
     extension=php_pdo_oci.dll
    重新启动 Apache 服务。这时,可以在 phpinfo 信息里看到 oci8 已经加载成功。?

    但是,运行PHP的测试代码,oci_connect()函数报错:
    oci_connect(): ORA-12154: TNS:could not resolve the connect identifier specified in ...
    pdo_oci报错:
    SQLSTATE[42S02]: pdo_oci_handle_factory: ORA-12154: TNS:could not resolve the connect identifier specified (ext\pdo_oci\oci_driver.c:631)

    解决:
    建立系统环境变量:
    TNS_ADMIN = D:\oracle_instantclient\instantclient_10_2
    NLS_LANG = AMERICAN_AMERICA.UTF8
    重新启动 Apache 服务。
    同时,需要 tnsnames.ora 网络配置文件(位于D:\oracle_instantclient\instantclient_10_2下),用于PHP去解析SERVICE_NAME,例如:
    # TNSNAMES.ORA Network Configuration File
    tns1 =
      (DESCRIPTION=
        (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL=TCP)(HOST = 10.0.0.90)(PORT = 1521))
        )
        (CONNECT_DATA=
          (SERVICE_NAME=mydb90)
        )
      )
    更改 tnsnames.ora 文件,需要重新启动 Apache 服务,从而让 PHP 识别新的 tnsnames.ora 配置。
    PHP 的 oci 连接示例:$conn=oci_connect("scott", "tiger", "tns1")。

    以上是 PHP 作为 Oracle 客户端,必须做的。
    Navicat8.2 for Oracle 作为 Oracle 管理客户端,只要配置 oci 指向 D:\oracle_instantclient\instantclient_10_2\oci.dll,即可连接到 Oracle 数据库服务器。

    张庆(网眼) ,微博:http://t.qq.com/zhangking
    来自“网眼视界”:http://blog.why100000.com
    “十万个为什么”电脑学习网:http://www.why100000.com
     2013-2-6

 

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)