省略安装BT面板和安装php8.0环境。
ps: 我这里使用了Oracle Cloud的arm vps
1.进入BT面板的PHP8.0的bin
cd /www/server/php/80/bin/
2.安装pear
参考php官方文档 https://www.php.net/manual/en/oci8.requirements.php
因为没有pecl这里需要安装pear
wget http://pear.php.net/go-pear.phar php go-pear.phar
一般一路下一步就好。
执行 pecl 来验证我们的安装效果吧。
3.安装Oracle Instant Client基础环境
参考oracle官方文档https://docs.oracle.com/en/database/oracle/machine-learning/oml4r/1.5.1/oread/installing-oracle-database-instant-client.html#GUID-33543D62-0EBD-49A5-97C9-94C4F0C4E90A
我在下载中心采用最新版,因此这里我们需要安装2个RPM分别是:
oracle-instantclient19.10-basic-19.10.0.0.0-1.aarch64.rpm oracle-instantclient19.10-devel-19.10.0.0.0-1.aarch64.rpm
准备好文件后直接按照官方文档进行安装
rpm -i oracle-instantclient19.10-basic-19.10.0.0.0-1.aarch64.rpm rpm -i oracle-instantclient19.10-devel-19.10.0.0.0-1.aarch64.rpm
4.安装oci8-3.0.1 (我使用的是php8.0,参考步骤1的php文档又具体各种版本对应)
注意:务必在php8.0的bin下执行!!
pecl install oci8-3.0.1
注意提供你在步骤3安装的Oracle Instant Client的lib目录,由于版本不一定一样以下仅供参考
[root@instance-20220113-1727 opc]# cd /usr/lib/oracle/19.10/client64/lib/ [root@instance-20220113-1727 lib]# ls libclntshcore.so libclntsh.so.10.1 libclntsh.so.18.1 libocci.so.19.1 liboramysql19.so ottclasses.zip libclntshcore.so.19.1 libclntsh.so.11.1 libclntsh.so.19.1 libociei.so network xstreams.jar libclntsh.so libclntsh.so.12.1 libnnz19.so libocijdbc19.so ojdbc8.jary
安装过程仅供参考:
[root@instance-20220113-1727 bin]# pecl install oci8-3.0.1 WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update downloading oci8-3.0.1.tgz ... Starting to download oci8-3.0.1.tgz (190,882 bytes) .........................................done: 190,882 bytes 13 source files, building running: phpize Configuring for: PHP Api Version: 20200930 Zend Module Api No: 20200930 Zend Extension Api No: 420200930 Please provide the path to the ORACLE_HOME directory. Use 'instantclient,/path/to/instant/client/lib' if you're compiling with Oracle Instant Client [autodetect] : instantclient,/usr/lib/oracle/19.10/client64/lib building in /tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1 running: /tmp/pear/install/oci8/configure --with-php-config=/www/server/php/80/bin/php-config --with-oci8=instantclient,/usr/lib/oracle/19.10/client64/lib checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for a sed that does not truncate output... /usr/bin/sed checking for pkg-config... /usr/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 checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether cc accepts -g... yes checking for cc option to accept ISO C89... none needed checking how to run the C preprocessor... cc -E checking for icc... no checking for suncc... no checking for system library directory... lib checking if compiler supports -Wl,-rpath,... yes checking build system type... aarch64-unknown-linux-gnu checking host system type... aarch64-unknown-linux-gnu checking target system type... aarch64-unknown-linux-gnu checking for PHP prefix... /www/server/php/80 checking for PHP includes... -I/www/server/php/80/include/php -I/www/server/php/80/include/php/main -I/www/server/php/80/include/php/TSRM -I/www/server/php/80/include/php/Zend -I/www/server/php/80/include/php/ext -I/www/server/php/80/include/php/ext/date/lib checking for PHP extension directory... /www/server/php/80/lib/php/extensions/no-debug-non-zts-20200930 checking for PHP installed headers prefix... /www/server/php/80/include/php checking if debug is enabled... no checking if zts is enabled... no checking for gawk... gawk checking for Oracle Database OCI8 support... yes, shared checking PHP version... 8.0.20, ok checking OCI8 DTrace support... no checking size of long... 8 checking if we're at 64-bit platform... yes checking Oracle Instant Client directory... /usr/lib/oracle/19.10/client64/lib checking Oracle Instant Client SDK header directory... /usr/include/oracle/19.10/client64 checking Oracle Instant Client library version compatibility... 19.1 checking for a sed that does not truncate output... /usr/bin/sed checking for ld used by cc... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... yes checking for /usr/bin/ld option to reload object files... -r checking for BSD-compatible nm... /usr/bin/nm -B checking whether ln -s works... yes checking how to recognize dependent libraries... pass_all checking dlfcn.h usability... yes checking dlfcn.h presence... yes checking for dlfcn.h... yes checking the maximum length of command line arguments... 1572864 checking command to parse /usr/bin/nm -B output from cc object... ok checking for objdir... .libs checking for ar... ar checking for ranlib... ranlib checking for strip... strip checking if cc supports -fno-rtti -fno-exceptions... no checking for cc option to produce PIC... -fPIC checking if cc PIC flag -fPIC works... yes checking if cc static flag -static works... no checking if cc supports -c -o file.o... yes checking whether the cc linker (/usr/bin/ld) supports shared libraries... yes checking whether -lc should be explicitly linked in... no checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... no creating libtool appending configuration tag "CXX" to libtool configure: patching config.h.in configure: creating ./config.status config.status: creating config.h running: make /bin/sh /tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/libtool --mode=compile cc -I. -I/tmp/pear/install/oci8 -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/include -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/main -I/tmp/pear/install/oci8 -I/www/server/php/80/include/php -I/www/server/php/80/include/php/main -I/www/server/php/80/include/php/TSRM -I/www/server/php/80/include/php/Zend -I/www/server/php/80/include/php/ext -I/www/server/php/80/include/php/ext/date/lib -I/usr/include/oracle/19.10/client64 -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/install/oci8/oci8.c -o oci8.lo mkdir .libs cc -I. -I/tmp/pear/install/oci8 -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/include -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/main -I/tmp/pear/install/oci8 -I/www/server/php/80/include/php -I/www/server/php/80/include/php/main -I/www/server/php/80/include/php/TSRM -I/www/server/php/80/include/php/Zend -I/www/server/php/80/include/php/ext -I/www/server/php/80/include/php/ext/date/lib -I/usr/include/oracle/19.10/client64 -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/install/oci8/oci8.c -fPIC -DPIC -o .libs/oci8.o /bin/sh /tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/libtool --mode=compile cc -I. -I/tmp/pear/install/oci8 -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/include -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/main -I/tmp/pear/install/oci8 -I/www/server/php/80/include/php -I/www/server/php/80/include/php/main -I/www/server/php/80/include/php/TSRM -I/www/server/php/80/include/php/Zend -I/www/server/php/80/include/php/ext -I/www/server/php/80/include/php/ext/date/lib -I/usr/include/oracle/19.10/client64 -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/install/oci8/oci8_lob.c -o oci8_lob.lo cc -I. -I/tmp/pear/install/oci8 -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/include -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/main -I/tmp/pear/install/oci8 -I/www/server/php/80/include/php -I/www/server/php/80/include/php/main -I/www/server/php/80/include/php/TSRM -I/www/server/php/80/include/php/Zend -I/www/server/php/80/include/php/ext -I/www/server/php/80/include/php/ext/date/lib -I/usr/include/oracle/19.10/client64 -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/install/oci8/oci8_lob.c -fPIC -DPIC -o .libs/oci8_lob.o /bin/sh /tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/libtool --mode=compile cc -I. -I/tmp/pear/install/oci8 -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/include -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/main -I/tmp/pear/install/oci8 -I/www/server/php/80/include/php -I/www/server/php/80/include/php/main -I/www/server/php/80/include/php/TSRM -I/www/server/php/80/include/php/Zend -I/www/server/php/80/include/php/ext -I/www/server/php/80/include/php/ext/date/lib -I/usr/include/oracle/19.10/client64 -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/install/oci8/oci8_statement.c -o oci8_statement.lo cc -I. -I/tmp/pear/install/oci8 -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/include -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/main -I/tmp/pear/install/oci8 -I/www/server/php/80/include/php -I/www/server/php/80/include/php/main -I/www/server/php/80/include/php/TSRM -I/www/server/php/80/include/php/Zend -I/www/server/php/80/include/php/ext -I/www/server/php/80/include/php/ext/date/lib -I/usr/include/oracle/19.10/client64 -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/install/oci8/oci8_statement.c -fPIC -DPIC -o .libs/oci8_statement.o /bin/sh /tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/libtool --mode=compile cc -I. -I/tmp/pear/install/oci8 -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/include -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/main -I/tmp/pear/install/oci8 -I/www/server/php/80/include/php -I/www/server/php/80/include/php/main -I/www/server/php/80/include/php/TSRM -I/www/server/php/80/include/php/Zend -I/www/server/php/80/include/php/ext -I/www/server/php/80/include/php/ext/date/lib -I/usr/include/oracle/19.10/client64 -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/install/oci8/oci8_collection.c -o oci8_collection.lo cc -I. -I/tmp/pear/install/oci8 -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/include -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/main -I/tmp/pear/install/oci8 -I/www/server/php/80/include/php -I/www/server/php/80/include/php/main -I/www/server/php/80/include/php/TSRM -I/www/server/php/80/include/php/Zend -I/www/server/php/80/include/php/ext -I/www/server/php/80/include/php/ext/date/lib -I/usr/include/oracle/19.10/client64 -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/install/oci8/oci8_collection.c -fPIC -DPIC -o .libs/oci8_collection.o /bin/sh /tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/libtool --mode=compile cc -I. -I/tmp/pear/install/oci8 -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/include -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/main -I/tmp/pear/install/oci8 -I/www/server/php/80/include/php -I/www/server/php/80/include/php/main -I/www/server/php/80/include/php/TSRM -I/www/server/php/80/include/php/Zend -I/www/server/php/80/include/php/ext -I/www/server/php/80/include/php/ext/date/lib -I/usr/include/oracle/19.10/client64 -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/install/oci8/oci8_interface.c -o oci8_interface.lo cc -I. -I/tmp/pear/install/oci8 -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/include -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/main -I/tmp/pear/install/oci8 -I/www/server/php/80/include/php -I/www/server/php/80/include/php/main -I/www/server/php/80/include/php/TSRM -I/www/server/php/80/include/php/Zend -I/www/server/php/80/include/php/ext -I/www/server/php/80/include/php/ext/date/lib -I/usr/include/oracle/19.10/client64 -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/install/oci8/oci8_interface.c -fPIC -DPIC -o .libs/oci8_interface.o /bin/sh /tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/libtool --mode=compile cc -I. -I/tmp/pear/install/oci8 -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/include -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/main -I/tmp/pear/install/oci8 -I/www/server/php/80/include/php -I/www/server/php/80/include/php/main -I/www/server/php/80/include/php/TSRM -I/www/server/php/80/include/php/Zend -I/www/server/php/80/include/php/ext -I/www/server/php/80/include/php/ext/date/lib -I/usr/include/oracle/19.10/client64 -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/install/oci8/oci8_failover.c -o oci8_failover.lo cc -I. -I/tmp/pear/install/oci8 -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/include -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/main -I/tmp/pear/install/oci8 -I/www/server/php/80/include/php -I/www/server/php/80/include/php/main -I/www/server/php/80/include/php/TSRM -I/www/server/php/80/include/php/Zend -I/www/server/php/80/include/php/ext -I/www/server/php/80/include/php/ext/date/lib -I/usr/include/oracle/19.10/client64 -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/install/oci8/oci8_failover.c -fPIC -DPIC -o .libs/oci8_failover.o /bin/sh /tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/libtool --mode=link cc -shared -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/include -I/tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/main -I/tmp/pear/install/oci8 -I/www/server/php/80/include/php -I/www/server/php/80/include/php/main -I/www/server/php/80/include/php/TSRM -I/www/server/php/80/include/php/Zend -I/www/server/php/80/include/php/ext -I/www/server/php/80/include/php/ext/date/lib -I/usr/include/oracle/19.10/client64 -DHAVE_CONFIG_H -g -O2 -o oci8.la -export-dynamic -avoid-version -prefer-pic -module -rpath /tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/modules oci8.lo oci8_lob.lo oci8_statement.lo oci8_collection.lo oci8_interface.lo oci8_failover.lo -Wl,-rpath,/usr/lib/oracle/19.10/client64/lib -L/usr/lib/oracle/19.10/client64/lib -lclntsh cc -shared .libs/oci8.o .libs/oci8_lob.o .libs/oci8_statement.o .libs/oci8_collection.o .libs/oci8_interface.o .libs/oci8_failover.o -L/usr/lib/oracle/19.10/client64/lib -lclntsh -Wl,-rpath -Wl,/usr/lib/oracle/19.10/client64/lib -Wl,-soname -Wl,oci8.so -o .libs/oci8.so creating oci8.la (cd .libs && rm -f oci8.la && ln -s ../oci8.la oci8.la) /bin/sh /tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/libtool --mode=install cp ./oci8.la /tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/modules cp ./.libs/oci8.so /tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/modules/oci8.so cp ./.libs/oci8.lai /tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/modules/oci8.la PATH="$PATH:/sbin" ldconfig -n /tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/modules ---------------------------------------------------------------------- Libraries have been installed in: /tmp/pear/install/pear-build-opcYagwDx/oci8-3.0.1/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'. running: make INSTALL_ROOT="/tmp/pear/install/pear-build-opcYagwDx/install-oci8-3.0.1" install Installing shared extensions: /tmp/pear/install/pear-build-opcYagwDx/install-oci8-3.0.1/www/server/php/80/lib/php/extensions/no-debug-non-zts-20200930/ running: find "/tmp/pear/install/pear-build-opcYagwDx/install-oci8-3.0.1" | xargs ls -dils 39828333 0 drwxr-xr-x 3 root root 17 Jul 28 10:07 /tmp/pear/install/pear-build-opcYagwDx/install-oci8-3.0.1 7902980 0 drwxr-xr-x 3 root root 20 Jul 28 10:07 /tmp/pear/install/pear-build-opcYagwDx/install-oci8-3.0.1/www 39828334 0 drwxr-xr-x 3 root root 17 Jul 28 10:07 /tmp/pear/install/pear-build-opcYagwDx/install-oci8-3.0.1/www/server 67673873 0 drwxr-xr-x 3 root root 16 Jul 28 10:07 /tmp/pear/install/pear-build-opcYagwDx/install-oci8-3.0.1/www/server/php 102334249 0 drwxr-xr-x 3 root root 17 Jul 28 10:07 /tmp/pear/install/pear-build-opcYagwDx/install-oci8-3.0.1/www/server/php/80 7902981 0 drwxr-xr-x 3 root root 17 Jul 28 10:07 /tmp/pear/install/pear-build-opcYagwDx/install-oci8-3.0.1/www/server/php/80/lib 39828335 0 drwxr-xr-x 3 root root 24 Jul 28 10:07 /tmp/pear/install/pear-build-opcYagwDx/install-oci8-3.0.1/www/server/php/80/lib/php 67673874 0 drwxr-xr-x 3 root root 39 Jul 28 10:07 /tmp/pear/install/pear-build-opcYagwDx/install-oci8-3.0.1/www/server/php/80/lib/php/extensions 102334250 0 drwxr-xr-x 2 root root 21 Jul 28 10:07 /tmp/pear/install/pear-build-opcYagwDx/install-oci8-3.0.1/www/server/php/80/lib/php/extensions/no-debug-non-zts-20200930 102334251 872 -rwxr-xr-x 1 root root 891240 Jul 28 10:07 /tmp/pear/install/pear-build-opcYagwDx/install-oci8-3.0.1/www/server/php/80/lib/php/extensions/no-debug-non-zts-20200930/oci8.so Build process completed successfully Installing '/www/server/php/80/lib/php/extensions/no-debug-non-zts-20200930/oci8.so' install ok: channel://pecl.php.net/oci8-3.0.1 configuration option "php_ini" is not set to php.ini location You should add "extension=oci8.so" to php.ini
5.进入bt面板在PHP下面的php.ini中加入
extension=oci8.so
6.重启PHP,完成!!