Linux下用PHP4连接ORACLE8I的方
时间:2007-02-17 来源:PHP爱好者
Linux下用PHP4连接ORACLE8I的方法
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
关键词:PHP
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
1. 下载并安装 Oracle 8i for linux.
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
完全安装,不要只安装客户端
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
下载地点:chat.hn.cninfo.net/soft的hot下载
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
2. 下载PHP3或PHP4源码
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
下载地点:www.php.net www.phpuser.com chat.hn.cninfo.net/soft
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
3. 配置PHP的安装参数
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
for php 4:
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
./configure --with-apxs=/usr/sbin/apxs
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--prefix=/usr
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-gd
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--enable-versioning
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-mysql=/usr
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-oracle=/usr/local/oracle/8i/u01/app/oracle/product/8.1.5
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-oci8=/usr/local/oracle/8i/u01/app/oracle/product/8.1.5
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-zlib
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-dbase
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-filepro
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-config-file-path=/etc/httpd/conf
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-fdftk=no
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--enable-debug=no
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--enable-magic-quotes
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--enable-debugger
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--enable-bcmath
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--enable-track-vars
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--enable-safe-mode
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-exec-dir=/usr/bin
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-system-regex
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--no-create
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--no-recursion
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-oracle 选项让php可以通过ORA_函数访问 Oracle 7.x 或8.x
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-oci8 选项让php可以使用更多更好的 oci8函数
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
4. make
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
5. make install
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
6. cp ./php.ini-dist /wherever/your/conf/files/are/php.ini
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
将php.ini拷贝到适当的位置
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
7. 修改httpd.conf
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
修改如下这一行
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
LoadModule php4_module lib/apache/libphp4.so
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
改为:
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
LoadModule php4_module /usr/lib/apache/libphp4.so
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
8. 重新启动APACHE
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
9. 测试PHP4的安装是否成功
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
创建一个test.php3内容为:
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
在浏览器中访问它,看是否有ORACLE和ORACLE8的信息。
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
如果有的话,那么就恭喜你了!
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
10. 现在开始使用ORACLE的函数吧
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
// 设置ORACLE环境变量
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
putenv("ORACLE_SID=PROD");
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
putenv("ORACLE_HOME=/usr/local/oracle/8i/u01/app/oracle/product/8.1.5");
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
// 建立连接
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
// 修改现在的user_id,password,db以适应你的配置
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
if($conn = OCILogon("user_id","password","db"))
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
{
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
// 取得数据库的信息
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
printf("%s
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
", OCIServerVersion($conn));
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
}
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
else
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
{
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
printf("Conncetion Failed");
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
}
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
?>
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
这段程序会显示出你所连接到的ORACLE的一些信息
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
12. 其它
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
如果你需要连接到远程的ORACLE服务器,你就还需要设置你的sqlnet.ora 和 tnsnames.ora 来指定远程数据库的位置。
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
向数据库管理员要求,拷贝一些文件放到$ORACLE_HOME/network/admin/ 目录下
php爱好者站 http://www.phpfans.net dreamweaver|flash|fireworks|photoshop.
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
关键词:PHP
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
1. 下载并安装 Oracle 8i for linux.
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
完全安装,不要只安装客户端
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
下载地点:chat.hn.cninfo.net/soft的hot下载
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
2. 下载PHP3或PHP4源码
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
下载地点:www.php.net www.phpuser.com chat.hn.cninfo.net/soft
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
3. 配置PHP的安装参数
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
for php 4:
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
./configure --with-apxs=/usr/sbin/apxs
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--prefix=/usr
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-gd
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--enable-versioning
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-mysql=/usr
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-oracle=/usr/local/oracle/8i/u01/app/oracle/product/8.1.5
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-oci8=/usr/local/oracle/8i/u01/app/oracle/product/8.1.5
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-zlib
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-dbase
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-filepro
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-config-file-path=/etc/httpd/conf
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-fdftk=no
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--enable-debug=no
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--enable-magic-quotes
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--enable-debugger
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--enable-bcmath
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--enable-track-vars
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--enable-safe-mode
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-exec-dir=/usr/bin
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-system-regex
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--no-create
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--no-recursion
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-oracle 选项让php可以通过ORA_函数访问 Oracle 7.x 或8.x
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
--with-oci8 选项让php可以使用更多更好的 oci8函数
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
4. make
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
5. make install
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
6. cp ./php.ini-dist /wherever/your/conf/files/are/php.ini
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
将php.ini拷贝到适当的位置
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
7. 修改httpd.conf
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
修改如下这一行
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
LoadModule php4_module lib/apache/libphp4.so
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
改为:
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
LoadModule php4_module /usr/lib/apache/libphp4.so
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
8. 重新启动APACHE
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
9. 测试PHP4的安装是否成功
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
创建一个test.php3内容为:
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
在浏览器中访问它,看是否有ORACLE和ORACLE8的信息。
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
如果有的话,那么就恭喜你了!
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
10. 现在开始使用ORACLE的函数吧
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
// 设置ORACLE环境变量
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
putenv("ORACLE_SID=PROD");
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
putenv("ORACLE_HOME=/usr/local/oracle/8i/u01/app/oracle/product/8.1.5");
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
// 建立连接
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
// 修改现在的user_id,password,db以适应你的配置
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
if($conn = OCILogon("user_id","password","db"))
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
{
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
// 取得数据库的信息
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
printf("%s
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
", OCIServerVersion($conn));
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
}
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
else
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
{
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
printf("Conncetion Failed");
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
}
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
?>
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
这段程序会显示出你所连接到的ORACLE的一些信息
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
12. 其它
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
如果你需要连接到远程的ORACLE服务器,你就还需要设置你的sqlnet.ora 和 tnsnames.ora 来指定远程数据库的位置。
chi na it p owe r .comnJecmGJG22UWEnXlat8aW2wac
向数据库管理员要求,拷贝一些文件放到$ORACLE_HOME/network/admin/ 目录下
php爱好者站 http://www.phpfans.net dreamweaver|flash|fireworks|photoshop.
相关阅读 更多 +