centos7 oci8安裝

laosan123發表於2021-10-16

centos7 oci8安裝

1.下載oracle檔案:必須和連線的oracle資料庫一致,如:連線的是11.0.2.4的oracle,下載的檔案就需要是11版本的。
以下的用11.0.2.4的oracle舉例操作:

下載地址:www.oracle.com/cn/database/technol...

下載的檔案:

1.oracle-instantclient11.1-basic-11.1.0.7.0-1.x86_64.rpm
2.oracle-instantclient11.1-devel-11.1.0.7.0-1.x86_64.rpm
3.oracle-instantclient11.1-sqlplus-11.1.0.7.0-1.x86_64.rpm

2.安裝oracle-instantclien

2.1進入到/usr/local/src/目錄,把下載好的rpm全部複製到該目錄下

[root@localhost src]# pwd
/usr/local/src
[root@localhost src]# ls
oci8                                                    oracle-instantclient11.1-devel-11.1.0.7.0-1.x86_64.rpm
oracle-instantclient11.1-basic-11.1.0.7.0-1.x86_64.rpm  oracle-instantclient11.1-sqlplus-11.1.0.7.0-1.x86_64.rpm

2.2安裝包

rpm -Uvh oracle-instantclient11.1-devel-11.1.0.7.0-1.x86_64.rpm
rpm -Uvh oracle-instantclient11.1-basic-11.1.0.7.0-1.x86_64.rpm
rpm -Uvh oracle-instantclient11.1-sqlplus-11.1.0.7.0-1.x86_64.rpm

2.3確認安裝完成

[root@localhost oracle]# ls
11.1
[root@localhost oracle]# 
[root@localhost oracle]# 
[root@localhost oracle]# pwd
/usr/lib/oracle
[root@localhost oracle]# 

3.新增php的oci擴充套件

3.1.進入編譯包

[root@localhost oci8]# pwd
/var/www/html/php-7.4.0/ext/oci8
[root@localhost oci8]# 

3.2./usr/local/php740/bin/phpize

[root@localhost oci8]# /usr/local/php740/bin/phpize
Configuring for:
PHP Api Version:         20190902
Zend Module Api No:      20190902
Zend Extension Api No:   320190902
[root@localhost oci8]# 

3.3 ./configure

[root@localhost oci8]# ./configure --with-php-config=/usr/local/php740/bin/php-config --with-oci8=shared,instantclient,/usr/lib/oracle/11.1/client64/lib
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for pkg-config... /bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out

3.4 make

[root@localhost oci8]# make && make install

PATH="$PATH:/sbin" ldconfig -n /var/www/html/php-7.4.0/ext/oci8/modules
----------------------------------------------------------------------
Libraries have been installed in:
 /var/www/html/php-7.4.0/ext/oci8/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.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/php740/lib/php/extensions/no-debug-non-zts-20190902/
[root@localhost oci8]# 

[root@localhost oci8]# cd /usr/local/php740/lib/php/extensions/no-debug-non-zts-20190902/
[root@localhost no-debug-non-zts-20190902]# ls
gd.so  libzip.so  mongodb.so  oci8.so  opcache.a  opcache.so  redis.so  swoole.so  xdebug.so  zip.so

4.1 引入

vim /usr/local/php740/lib/php.ini
下面每種都可
extension=/usr/local/php740/lib/php/extensions/no-debug-non-zts-20190902/oci8.so
extenstion=oci8.so
本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章