markdown 安装Oracle PHP扩展(oracle OCI8) - 适用于Mac OS 10.12.6的即时客户端 - 自制环境 - 在PHP 7.2上

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 安装Oracle PHP扩展(oracle OCI8) - 适用于Mac OS 10.12.6的即时客户端 - 自制环境 - 在PHP 7.2上相关的知识,希望对你有一定的参考价值。

# Installation

This procedure is tested on Mac OS X 10.12.6 

PHP 7.2 installed with Homebrew.

## Preparation

Download the following files from [Oracle website](http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html) (yes, you need to create an account and accept terms):

 * [instantclient-basic-macos.x64-12.2.0.1.0-2.zip](http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html)
 * [instantclient-sqlplus-macos.x64-12.2.0.1.0-2.zip](http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html)
 * [instantclient-sdk-macos.x64-12.2.0.1.0-2.zip](http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html)

Create and unzip all theses files into a the directory `/usr/local/instantclient/12.2.0.1/`.

## Create symlinks

```bash
sudo ln -s /usr/local/instantclient/12.2.0.1/sdk/include/*.h /usr/local/include/
sudo ln -s /usr/local/instantclient/12.2.0.1/sqlplus /usr/local/bin/
sudo ln -s /usr/local/instantclient/12.2.0.1/*.dylib /usr/local/lib/
sudo ln -s /usr/local/instantclient/12.2.0.1/*.dylib.12.1 /usr/local/lib/
sudo ln -s /usr/local/lib/libclntsh.dylib.12.1 /usr/local/lib/libclntsh.dylib
```

## Install extension with pecl

```
pecl install oci8
```

On success installation, you will have messages like the following:

```
Build process completed successfully
Installing '/usr/local/Cellar/php/7.2.7/pecl/20170718/oci8.so'
install ok: channel://pecl.php.net/oci8-2.1.8
Extension oci8 enabled in php.ini
```

If the script prompt you to provide the path to ORACLE_HOME directory, respond with:
```
instantclient,/usr/local/lib
```

And your are done, normally pecl will automatically load the extension in your `php.ini`. If not, add the following line to your `php.ini`:

> Run `php --ini` to check your `php.ini` file location.

```
extension=oci8.so
```

Then do test the setup by running `php -v`. 

If you are having error code like the following:

```
Warning: PHP Startup: Unable to load dynamic library 'oci8.so' (tried: /usr/local/Cellar/php/7.2.7/lib/php/20170718/oci8.so (dlopen(/usr/local/Cellar/php/7.2.7/lib/php/20170718/oci8.so, 9): image not found), /usr/local/Cellar/php/7.2.7/lib/php/20170718/oci8.so.so (dlopen(/usr/local/Cellar/php/7.2.7/lib/php/20170718/oci8.so.so, 9): image not found)) in Unknown on line 0
```

You can copy the `oci8.so` generated to the target path. In above case as following:

```
cp /usr/local/Cellar/php/7.2.7/pecl/20170718/oci8.so /usr/local/Cellar/php/7.2.7/lib/php/20170718/
```

Then you should see no more error message when runninng `php -v`.

Restart your HTTP Server and test.

Enjoy (or try to...) !

以上是关于markdown 安装Oracle PHP扩展(oracle OCI8) - 适用于Mac OS 10.12.6的即时客户端 - 自制环境 - 在PHP 7.2上的主要内容,如果未能解决你的问题,请参考以下文章

php安装oracle扩展

Windows安装php Oracle扩展

PHP 7 编译安装开启 libevent 扩展支持

windows下安装oracle客户端和php扩展

PHP libevent扩展安装

PHP7 安装 event 扩展