php oracle pdo_mysql

准备安装环境:
CentOS release 6.3 (Final)
查看linux内核版本、系统信息: uname -a;   more /etc/issue; cat /proc/version

php5.3
查看php版本 php -v

nginx1.6
查看nginx版本 nginx -v

需要安装:oracle客户端、pdo_oci扩展、oci8扩展
1.下载oracle客户端:
下载地址:http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm
oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm

2.安装oracle客户端
rpm -ivh oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm

3.配置oracle
1)添加动态加载器
echo "/usr/lib/oracle/12.1/client64/lib/" > /etc/ld.so.conf.d/oracle_client.conf
/sbin/ldconfig

4.下载oci8
wget http://pecl.php.net/get/oci8-2.0.8.tgz
tar oci8-2.0.8.tgz
cd oci8-2.0.8

5.编译安装
CFLAGS="-I/usr/lib/oracle/12.1/client64"
CXXFLAGS="-I/usr/lib/oracle/12.1/client64"
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-oci8=shared,instantclient,/usr/lib/oracle/12.1/client64/lib
make && make install

6.在php.ini配置文件增加扩展
/usr/local/php/etc/php.ini
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626"
extension = "oci8.so"

7.因为修改了php.ini需要重新加载配置文件,安装完成后需要重启 PHP-FPM (FastCGI Process Manager) 
ps -ef |grep 'php-fpm'        查看进程
kill -QUIT 1821                     退出
php-fpm -t php.ini              测试php-fpm配置
php-fpm -c php.ini              指定加载php.ini 配置文件
php -i | grep 'oci'                 查看是否安装成功

 

另:如果报这个错:
ORA-24408: could not generate unique server group name
如果设置了主机名需要在 /etc/host 增加:127.0.0.1  localhost.localdomain  php-uat01
查看主机名:export

 

 

PHP pdo_mysql
1. 找到php的phpize
[root@php1 bin]# cd /opt/php-5.3.28/ext/pdo_mysql
[root@php1 sockets]# /usr/local/php/bin/phpize  
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
[root@php1 sockets]#./configure --with-php-config=/usr/local/php/bin/php-config
[root@php1 sockets]#make && make install
----------------------------------------------------------------------
Libraries have been installed in:
   /opt/php-5.3.28/ext/pdo_mysql/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'.

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/

 

你可能感兴趣的:(php oracle pdo_mysql)