準備安裝環境:
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/