ubuntu 14.04 LTS 安装PHP orcale PDO_OCI支持

1 安装依懒

aptitude install php5-dev build-essential php-pear libaio1 unzip  make

2 下载官方包

http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

下载basic和sdk两个包

3 准备

设立目录,解压缩:

#sudo mkdir /opt/oracle
#sudo cp ~/*.zip /opt/oracle
#cd /opt/oracle
#sudo unzip ./*.zip
#sudo mv instantclient_10_1 instantclient

设置instantclient:

#sudo ln –s libclntsh.so.10.1 libclntsh.so
#sudo ln –s libocci.so.10.1 libocci.so
#export ORACLE_HOME=/opt/oracle/instantclient

添加lib库位置:

#cd /etc/ld.so.conf.d
#sudo nano liboci.conf  //添加一行:/opt/oracle/instantclient
#sudo ldconfig

4 编译

sudo pecl install oci8

5 设置 php.ini

sudo sh -c 'echo extension=oci8.so > /etc/php5/mods-available/oci8.ini'
ln -s /etc/php5/mods-available/oci8.ini /etc/php5/fpm/conf.d/20-oci8.ini

6 安装 pdo_oci

sudo mkdir -p /tmp/pear/download/
cd /tmp/pear/download/
sudo pecl download pdo_oci
sudo tar xvf PDO_OCI-1.0.tgz
cd PDO_OCI-1.0

打上补丁

sudo sed -i -e 's/function_entry pdo_oci_functions/zend_function_entry pdo_oci_functions/' pdo_oci.c

编译安装

sudo phpize
sudo mkdir -p /opt/oracle/instantclient/lib/oracle/10.1
sudo ln -s /opt/oracle/instantclient/sdk /opt/oracle/instantclient/lib/oracle/10.1/client
sudo ln -s /opt/oracle/instantclient /opt/oracle/instantclient/lib/oracle/10.1/client/lib
sudo ln -s /usr/include/php5 /usr/include/php
sudo ./configure --with-pdo-oci=instantclient,/opt/oracle/instantclient,10.1
sudo make
sudo make install

sudo sh -c 'echo extension=pdo_oci.so > /etc/php5/mods-available/pdo_oci.ini'

ln -s /etc/php5/mods-available/pdo_oci.ini /etc/php5/fpm/conf.d/20-pdo_oci.ini

重启php-fpm

kill -USR2 `cat /var/run/php5-fpm.pid`

你可能感兴趣的:(oracle,PHP)