PHP下的Oracle客戶端擴(kuò)展(OCI8)安裝教程
最近的項(xiàng)目需要用php訪問oracle數(shù)據(jù)庫(kù),不得不在linux下給php安裝oci8擴(kuò)展。php也可以使用pdo訪問oracle數(shù)據(jù)庫(kù),但還是需要安裝客戶端。
首先到oracle官網(wǎng)的這個(gè)頁(yè)面下載相關(guān)的文件,注意要連數(shù)據(jù)庫(kù)服務(wù)器的版本,一定要對(duì)應(yīng),否則安裝成功也會(huì)連不上,同時(shí)也要區(qū)分32位、64位服務(wù)器,比如我要連的數(shù)據(jù)庫(kù)服務(wù)器是oracle10.2.0.4,64位主機(jī),那么我要下載下面三個(gè)文件:
oracle-instantclient-basic-10.2.0.4-1.x86_64.rpm
oracle-instantclient-devel-10.2.0.4-1.x86_64.rpm
oracle-instantclient-sqlplus-10.2.0.4-1.x86_64.rpm
1.用以下命令安裝
# rpm -ivh oracle-instantclient-basic-10.2.0.4-1.x86_64.rpm oracle-instantclient-devel-10.2.0.4-1.x86_64.rpm oracle-instantclient-sqlplus-10.2.0.4-1.x86_64.rpm
2.安裝OCI8 PHP擴(kuò)展
# yum install libaio
# cd ~
# wget http://pecl.php.net/get/oci8-1.3.5.tgz
3.然后執(zhí)行命令
# tar zxvf oci8-1.3.5.tgz
# cd oci8-1.3.5/
# /usr/local/php5/bin/phpize CFLAGS=/usr/lib/oracle/11.2/client64/ CXXFLAGS=/usr/lib/oracle/11.2/client64/
# ./configure --with-php-config=/usr/local/php5/bin/php-config --with-oci8=instantclient,/usr/lib/oracle/11.2/client64/lib/
# make
# make install(這里多運(yùn)行幾次,直到出現(xiàn)如下提示)
[root@webserver02 oci8-1.3.5]# make install
/bin/sh /root/oci8-1.3.5/libtool --mode=install cp ./oci8.la /root/oci8-1.3.5/modules
cp ./.libs/oci8.so /root/oci8-1.3.5/modules/oci8.so
cp ./.libs/oci8.lai /root/oci8-1.3.5/modules/oci8.la
PATH="$PATH:/sbin" ldconfig -n /root/oci8-1.3.5/modules
----------------------------------------------------------------------
Libraries have been installed in:
/root/oci8-1.3.5/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Installing shared extensions: /usr/local/php5/lib/php/extensions/no-debug-zts-20090626/
# cd /usr/local/php5/lib
4.創(chuàng)建ext目錄
# mkdir ext/
把oci8.so文件拷貝到php.ini 的ext目錄里面
5.在php.ini里面加上extension=oci8.so
如下:
extension_dir = "/usr/local/php5/lib/ext"
extension = "oci8.so"
session.save_path = "/tmp/php"
oci8.privileged_connect = on
重啟apache服務(wù):
/usr/local/apache2/bin/apachectl stop
/usr/local/apache2/bin/apachectl start
刷新測(cè)試頁(yè)面。發(fā)現(xiàn)oci8出現(xiàn)了,則大功告成.
- 用PHP調(diào)用Oracle存儲(chǔ)過程的方法
- 用PHP調(diào)用Oracle存儲(chǔ)過程
- php連接oracle數(shù)據(jù)庫(kù)及查詢數(shù)據(jù)的方法
- ThinkPHP 連接Oracle數(shù)據(jù)庫(kù)的詳細(xì)教程[全]
- Linux+php+apache+oracle環(huán)境搭建之CentOS下源碼編譯安裝PHP
- 操作Oracle的php類
- PHP處理Oracle的CLOB實(shí)例
- 用PHP連接Oracle數(shù)據(jù)庫(kù)
- php+oracle 分頁(yè)類
- php 訪問oracle 存儲(chǔ)過程實(shí)例詳解
相關(guān)文章
php 網(wǎng)頁(yè)游戲開發(fā)入門教程一(webgame+design)
網(wǎng)頁(yè)游戲開發(fā)入門教程一 webgame+design , 大家可以參考下。2009-10-10Laravel 模型關(guān)聯(lián)基礎(chǔ)教程詳解
這篇文章主要介紹了Laravel 模型關(guān)聯(lián)基礎(chǔ)教程詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-09-09php下幾個(gè)常用的去空、分組、調(diào)試數(shù)組函數(shù)
dump() 把數(shù)組以數(shù)組格式數(shù)組,有益于調(diào)試 array_chunk() php默認(rèn)函數(shù) 作用是把函數(shù)平均分組2009-02-02php求兩個(gè)目錄的相對(duì)路徑示例(php獲取相對(duì)路徑)
這篇文章主要介紹了php求兩個(gè)目錄的相對(duì)路徑示例(php獲取相對(duì)路徑),需要的朋友可以參考下2014-03-03將博客園(cnblogs.com)數(shù)據(jù)導(dǎo)入到wordpress的代碼
博客園限制太多,于是決定從博客園(cnblogs)更換自己個(gè)人的博客。WORDPRESS口碑還不錯(cuò),于是決定用用看。之前發(fā)的數(shù)百篇日志需要導(dǎo)入過來,在網(wǎng)上搜了一會(huì),發(fā)現(xiàn)沒有這個(gè)插件,無奈只能自己寫一個(gè)2013-01-01php 生成靜態(tài)頁(yè)面的辦法與實(shí)現(xiàn)代碼詳細(xì)版
首先說原理。查了那么多資料,發(fā)現(xiàn)不管用什么方法,原理都是一樣的。就是用程序讀取相應(yīng)的數(shù)據(jù)來替換模版中的變量,然后生成靜態(tài)頁(yè)。2010-02-02