Windows2003 + PHP5.4.7 + Apache2.2.15 + Oracle9.0
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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

