PHP+IIS7配置OCI8链接Oracle 10G的方法
程序员文章站
2022-04-19 11:13:33
1. 下载适用于oracle10g的 instant client package 32bit,instantclient-basic-win32-10.2.0....
1. 下载适用于oracle10g的 instant client package 32bit,instantclient-basic-win32-10.2.0.5.zip,(如果你是64bit系统,),解压。
2.如果不修改系统path,那么解压出来的9个文件,全部放到php的bin目录下,也就是含有php二进制文件的那个目录下,如果有洁癖,那就改个path。
3.在iis的fastcgi下面选择环境变量编辑 添加如下三个变量
复制代码 代码如下:
nls_lang=simplified chinese_china.zhs16gbk
oracle_home=\path\to\php-bin
tns_admin=\path\to\the-location-of-tnsnames.ora-file
4.在php.ini里面把php_oci8.dll扩展启用
5.结束掉老的php-cgi进程重新访问就可以了
番外:
php官方对于oracle的连接时候的一些变量有说明,这里的环境变量,除了oracle_home之类的也不是必须的,官方都有对应的写法,可以看说明
name | purpose |
---|---|
oracle_home | contains the directory of the full oracle database software. do not set this when using oracle instant client as it is unnecessary and may cause installation problems. |
oracle_sid | contains the name of the database on the local machine to be connected to. there is no need to set this if you using oracle instant client, or always pass the connection parameter to. |
ld_library_path | set this (or its platform equivalent, such as dyld_library_path, libpath, or shlib_path) to the location of the oracle libraries, for example $oracle_home/lib or/usr/lib/oracle/11.1/client/lib. this variable is not needed if the libraries are located by a different search mechanism, such as with ldconfig or with ld_preload. |
nls_lang | this is the primary variable for setting the character set and globalization information used by the oracle libraries. |
ora_sdtz | sets the oracle session timezone. |
tns_admin | contains the directory where the oracle net services configuration files such as tnsnames.ora and sqlnet.ora are kept. not needed if the connection string uses the easy connect naming syntax such as localhost/xe. not needed if the network configuration files are in one of the default locations such as $oracle_home/network/admin or /etc. |
less frequently used oracle environment variables include two_task, ora_tzfile, and the various oracle globalization settings like nls* and the ora_nls_* variables.
oci_connect的时候,如果使用完整的tns语法或者简略的写法,比如8.8.8.8/abc的时候,tns_admin也不是必须的。具体的还是看官方文档吧,不多说了。