根据需要下载指定版本文件:
Oracle for macOS 驱动下载页
https://www.oracle.com/database/technologies/instant-client/macos-intel-x86-downloads.html
下载的文件列表:
instantclient-basic-macos.x64-12.2.0.1.0-2.zip
instantclient-sdk-macos.x64-12.2.0.1.0-2.zip
instantclient-sqlplus-macos.x64-12.2.0.1.0-2.zip
PHP oci8 扩展下载页
https://pecl.php.net/package/oci8
下载 oci8-2.2.0.tgz
解压这几个文件到一个固定目录(未来不要删除的那种):
/Users/tony/apps/plugins/php-oracle/instantclient_12_2
然后做个软链接:
sudo ln -s /Users/tony/apps/plugins/php-oracle/instantclient_12_2 /usr/local/instantclient
开始编译安装:
cd /Users/tony/apps/plugins/php-oracle/oci8-2.2.0/oci8-2.2.0
phpize
./configure –with-oci8=shared,instantclient,/usr/local/instantclient –with-php-config=/usr/local/opt/php@7.2/bin/php-config
make && make install
最后查看状态:
ll /usr/local/Cellar/php@7.2/7.2.28/pecl/20170718
可以看到 oci8.so 扩展已经编译安装成果。
现在修改配置文件:
vim /usr/local/etc/php/7.2/php.ini
找到 Dynamic Extensions 配置部分,添加一行:
extension=oci8.so
就可以了。