PHP下的Oracle客户端扩展(OCI8)安装教程
最近的项目需要用php访问oracle数据库,不得不在linux下给php安装oci8扩展。php也可以使用pdo访问oracle数据库,但还是需要安装客户端。
首先到oracle官网的这个页面下载相关的文件,注意要连数据库服务器的版本,一定要对应,否则安装成功也会连不上,同时也要区分32位、64位服务器,比如我要连的数据库服务器是oracle10.2.0.4,64位主机,那么我要下载下面三个文件:
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-ivhoracle-instantclient-basic-10.2.0.4-1.x86_64.rpmoracle-instantclient-devel-10.2.0.4-1.x86_64.rpm oracle-instantclient-sqlplus-10.2.0.4-1.x86_64.rpm
2.安装OCI8PHP扩展
#yuminstalllibaio #cd~ #wgethttp://pecl.php.net/get/oci8-1.3.5.tgz
3.然后执行命令
#tarzxvfoci8-1.3.5.tgz #cdoci8-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 #makeinstall(这里多运行几次,直到出现如下提示) [root@webserver02oci8-1.3.5]#makeinstall /bin/sh/root/oci8-1.3.5/libtool--mode=installcp./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 ---------------------------------------------------------------------- Librarieshavebeeninstalledin: /root/oci8-1.3.5/modules
Ifyoueverhappentowanttolinkagainstinstalledlibraries inagivendirectory,LIBDIR,youmusteitheruselibtool,and specifythefullpathnameofthelibrary,orusethe`-LLIBDIR' flagduringlinkinganddoatleastoneofthefollowing: -addLIBDIRtothe`LD_LIBRARY_PATH'environmentvariable duringexecution -addLIBDIRtothe`LD_RUN_PATH'environmentvariable duringlinking -usethe`-Wl,--rpath-Wl,LIBDIR'linkerflag -haveyoursystemadministratoraddLIBDIRto`/etc/ld.so.conf'
Seeanyoperatingsystemdocumentationaboutsharedlibrariesfor moreinformation,suchastheld(1)andld.so(8)manualpages. ---------------------------------------------------------------------- Installingsharedextensions: /usr/local/php5/lib/php/extensions/no-debug-zts-20090626/ #cd/usr/local/php5/lib