[PHP, OCI8] yum経由でphp-oci8をインストールした場合のoracleクライアント系soの置き場

## 結論
``/usr/lib64`` でした。



### 環境
```c:
$ cat /etc/redhat-release
CentOS release 6.5 (Final)
```

### PHP バージョン
```c:
$ php -v
PHP 5.6.0 (cli) (built: Sep  3 2014 19:58:48)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies

```

### oci8 のインストール
```c:
# yum install --enablerepo=remi-php56 php-oci8.x86_64

Dependencies Resolved

====================================================================================================
 Package                Arch             Version                         Repository            Size
====================================================================================================
Installing:
 php-oci8               x86_64           5.6.0-1.el6.remi.2              remi-php56           128 k
Updating for dependencies:
 php                    x86_64           5.6.0-1.el6.remi.2              remi-php56           2.6 M
 php-cli                x86_64           5.6.0-1.el6.remi.2              remi-php56           3.7 M
 php-common             x86_64           5.6.0-1.el6.remi.2              remi-php56           1.0 M
 php-mbstring           x86_64           5.6.0-1.el6.remi.2              remi-php56           961 k
 php-mcrypt             x86_64           5.6.0-1.el6.remi.2              remi-php56            43 k
 php-mysqlnd            x86_64           5.6.0-1.el6.remi.2              remi-php56           269 k
 php-opcache            x86_64           5.6.0-1.el6.remi.2              remi-php56           117 k
 php-pdo                x86_64           5.6.0-1.el6.remi.2              remi-php56           112 k
 php-process            x86_64           5.6.0-1.el6.remi.2              remi-php56            56 k
 php-xml                x86_64           5.6.0-1.el6.remi.2              remi-php56           208 k

Transaction Summary
====================================================================================================
Install       1 Package(s)
Upgrade      10 Package(s)

Total download size: 9.2 M
Is this ok [y/N]: y
Downloading Packages:
(1/11): php-5.6.0-1.el6.remi.2.x86_64.rpm                                    | 2.6 MB     00:12
(2/11): php-cli-5.6.0-1.el6.remi.2.x86_64.rpm                                | 3.7 MB     00:16
(3/11): php-common-5.6.0-1.el6.remi.2.x86_64.rpm                             | 1.0 MB     00:04
(4/11): php-mbstring-5.6.0-1.el6.remi.2.x86_64.rpm                           | 961 kB     00:04
(5/11): php-mcrypt-5.6.0-1.el6.remi.2.x86_64.rpm                             |  43 kB     00:00
(6/11): php-mysqlnd-5.6.0-1.el6.remi.2.x86_64.rpm                            | 269 kB     00:01
(7/11): php-oci8-5.6.0-1.el6.remi.2.x86_64.rpm                               | 128 kB     00:00
(8/11): php-opcache-5.6.0-1.el6.remi.2.x86_64.rpm                            | 117 kB     00:00
(9/11): php-pdo-5.6.0-1.el6.remi.2.x86_64.rpm                                | 112 kB     00:00
(10/11): php-process-5.6.0-1.el6.remi.2.x86_64.rpm                           |  56 kB     00:00
(11/11): php-xml-5.6.0-1.el6.remi.2.x86_64.rpm                               | 208 kB     00:00
----------------------------------------------------------------------------------------------------
Total                                                               211 kB/s | 9.2 MB     00:44
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : php-common-5.6.0-1.el6.remi.2.x86_64                                            1/21

WARNING : These php-* RPM are not official Fedora / Red Hat build and
overrides the official ones. Don't file bugs on Fedora Project nor Red Hat.

Use dedicated forums http://forums.famillecollet.com/

  Updating   : php-pdo-5.6.0-1.el6.remi.2.x86_64                                               2/21
  Updating   : php-cli-5.6.0-1.el6.remi.2.x86_64                                               3/21
  Updating   : php-5.6.0-1.el6.remi.2.x86_64                                                   4/21
  Updating   : php-mysqlnd-5.6.0-1.el6.remi.2.x86_64                                           5/21
  Installing : php-oci8-5.6.0-1.el6.remi.2.x86_64                                              6/21
  Updating   : php-process-5.6.0-1.el6.remi.2.x86_64                                           7/21
  Updating   : php-mbstring-5.6.0-1.el6.remi.2.x86_64                                          8/21
  Updating   : php-mcrypt-5.6.0-1.el6.remi.2.x86_64                                            9/21
  Updating   : php-opcache-5.6.0-1.el6.remi.2.x86_64                                          10/21
  Updating   : php-xml-5.6.0-1.el6.remi.2.x86_64                                              11/21
  Cleanup    : php-5.6.0-1.el6.remi.1.x86_64                                                  12/21
  Cleanup    : php-cli-5.6.0-1.el6.remi.1.x86_64                                              13/21
  Cleanup    : php-xml-5.6.0-1.el6.remi.1.x86_64                                              14/21
  Cleanup    : php-opcache-5.6.0-1.el6.remi.1.x86_64                                          15/21
  Cleanup    : php-mysqlnd-5.6.0-1.el6.remi.1.x86_64                                          16/21
  Cleanup    : php-pdo-5.6.0-1.el6.remi.1.x86_64                                              17/21
  Cleanup    : php-mcrypt-5.6.0-1.el6.remi.1.x86_64                                           18/21
  Cleanup    : php-mbstring-5.6.0-1.el6.remi.1.x86_64                                         19/21
  Cleanup    : php-process-5.6.0-1.el6.remi.1.x86_64                                          20/21
  Cleanup    : php-common-5.6.0-1.el6.remi.1.x86_64                                           21/21
  Verifying  : php-common-5.6.0-1.el6.remi.2.x86_64                                            1/21
  Verifying  : php-process-5.6.0-1.el6.remi.2.x86_64                                           2/21
  Verifying  : php-5.6.0-1.el6.remi.2.x86_64                                                   3/21
  Verifying  : php-mbstring-5.6.0-1.el6.remi.2.x86_64                                          4/21
  Verifying  : php-pdo-5.6.0-1.el6.remi.2.x86_64                                               5/21
  Verifying  : php-mcrypt-5.6.0-1.el6.remi.2.x86_64                                            6/21
  Verifying  : php-mysqlnd-5.6.0-1.el6.remi.2.x86_64                                           7/21
  Verifying  : php-opcache-5.6.0-1.el6.remi.2.x86_64                                           8/21
  Verifying  : php-oci8-5.6.0-1.el6.remi.2.x86_64                                              9/21
  Verifying  : php-cli-5.6.0-1.el6.remi.2.x86_64                                              10/21
  Verifying  : php-xml-5.6.0-1.el6.remi.2.x86_64                                              11/21
  Verifying  : php-cli-5.6.0-1.el6.remi.1.x86_64                                              12/21
  Verifying  : php-xml-5.6.0-1.el6.remi.1.x86_64                                              13/21
  Verifying  : php-process-5.6.0-1.el6.remi.1.x86_64                                          14/21
  Verifying  : php-5.6.0-1.el6.remi.1.x86_64                                                  15/21
  Verifying  : php-mysqlnd-5.6.0-1.el6.remi.1.x86_64                                          16/21
  Verifying  : php-mbstring-5.6.0-1.el6.remi.1.x86_64                                         17/21
  Verifying  : php-mcrypt-5.6.0-1.el6.remi.1.x86_64                                           18/21
  Verifying  : php-pdo-5.6.0-1.el6.remi.1.x86_64                                              19/21
  Verifying  : php-common-5.6.0-1.el6.remi.1.x86_64                                           20/21
  Verifying  : php-opcache-5.6.0-1.el6.remi.1.x86_64                                          21/21

Installed:
  php-oci8.x86_64 0:5.6.0-1.el6.remi.2

Dependency Updated:
  php.x86_64 0:5.6.0-1.el6.remi.2                  php-cli.x86_64 0:5.6.0-1.el6.remi.2
  php-common.x86_64 0:5.6.0-1.el6.remi.2           php-mbstring.x86_64 0:5.6.0-1.el6.remi.2
  php-mcrypt.x86_64 0:5.6.0-1.el6.remi.2           php-mysqlnd.x86_64 0:5.6.0-1.el6.remi.2
  php-opcache.x86_64 0:5.6.0-1.el6.remi.2          php-pdo.x86_64 0:5.6.0-1.el6.remi.2
  php-process.x86_64 0:5.6.0-1.el6.remi.2          php-xml.x86_64 0:5.6.0-1.el6.remi.2

Complete!

```

### oci8 のチェック
```c:
$ php -i | grep oci8
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/oci8.so' - libclntsh.so.12.1: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo_oci.so' - libclntsh.so.12.1: cannot open shared object file: No such file or directory in Unknown on line 0
/etc/php.d/20-oci8.ini,
/etc/php.d/30-pdo_oci.ini,

```

ほう、、PHP5.6 から 12系が要求されるのか。。


### クライアントライブラリの設置

12系のライブラリ群を入手し、``/usr/lib64`` にコピー

```c:
# cp libclntshcore.so.12.1 libclntsh.so.12.1 libnnz12.so libocci.so.12.1 libociicus.so libocijdbc12.so libons.so liboramysql12.so libsqlplusic.so libsqlplus.so /usr/lib64/

```


### ふたたび oci8 のチェック
```c:
$ php -i | grep oci8
/etc/php.d/20-oci8.ini,
/etc/php.d/30-pdo_oci.ini,
oci8
oci8.connection_class => no value => no value
oci8.default_prefetch => 100 => 100
oci8.events => Off => Off
oci8.max_persistent => -1 => -1
oci8.old_oci_close_semantics => Off => Off
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
PDO drivers => mysql, oci, sqlite

```

### 接続テスト
```php:
<?php
$dsn  = 'oci:dbname='.$dbhost.':'.$dbport.'/'.$dbname;
$user = 'user';
$pass = 'password';

try {
  $dbh = new PDO($dsn, $user, $pass);
  echo "OK";
} catch (PDOException $e) {
  echo $e->getMessage()."\n";
}

```



### 接続できないとき
#### 実行ユーザーの環境変数を確認
 * ``NLS_LANG=Japanese_Japan.***`` が設定されているか
 * ``ORACLE_HOME=/usr/lib64/`` が設定されているか
 * ``LD_LIBRARY_PATH=/usr/lib64/`` が設定されているか

#### マシン設定を確認
 * ``/etc/sysconfig/network`` のHOSTNAMEが ``/etc/hosts`` に記載されているか