windows
- 下载: instant-client
Oracle Instant Client Downloads
Instant Client for Microsoft Windows (x64) 64-bit (oracle.com)
下载12.1.*****版本的
打开压缩包将 oci.dll 复制到
C:\Windows\System32目录(网上说64位系统复制到 C:\Windows\SysWOW64目录,其实不管用)
下载 oci dll 库文件,根据php的版本选择
PECL :: Package :: oci8 (php.net)编辑php.ini
extension=php_oci8_12c.dll
Q: error:oci_connect(): OCIEnvNlsCreate() failed. ...... please check that PATH includes the directory with Oracle Instant Client libraries
A: instantlient 目录下的 dll 复制到system32目录
CI3
$db['GAME_DB']['dsn'] = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.16.201.18)(PORT=1521))(CONNECT_DATA=(SID=xe)))';
$db['GAME_DB']['username'] = 'dbxxxx';
$db['GAME_DB']['password'] = '123456';
$db['GAME_DB']['database'] = 'R2BEAT';
$db['GAME_DB']['dbdriver'] = 'oci8';
$db['GAME_DB']['dbprefix'] = '';
$db['GAME_DB']['pconnect'] = false;
$db['GAME_DB']['db_debug'] = TRUE;
$db['GAME_DB']['cache_on'] = FALSE;
$db['GAME_DB']['cachedir'] = '';
$db['GAME_DB']['char_set'] = '';//'utf8';
$db['GAME_DB']['dbcollat'] = '';
$db['GAME_DB']['swap_pre'] = '';
$db['GAME_DB']['autoinit'] = TRUE;
$db['GAME_DB']['stricton'] = FALSE;
ok啦 , 老铁们~~~~
LINUX (CentOS Linux release 7.9.2009)
Instant Client for Linux x86-64 (64-bit) (oracle.com)
php.net 官网下载 php7.4 编译安装
// 安装编译工具
yum groupinstall 'Development Tools'
// 安装依赖包
yum install oniguruma-devel
yum install libsqlite3x-devel -y
yum install -y epel-release
yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses curl gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel expat-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmcrypt-devel libmemcached-devel
./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc--with-fpm-user=www --with-fpm-group=www --with-curl --with-freetype-dir --enable-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl--with-zlib --with-bz2--with-mhash --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip --enable-fpm
Installing shared extensions: /usr/local/php7/lib/php/extensions/no-debug-non-zts-20190902/
Installing PHP CLI binary: /usr/local/php7/bin/
Installing PHP CLI man page: /usr/local/php7/php/man/man1/
Installing PHP FPM binary: /usr/local/php7/sbin/
Installing PHP FPM defconfig: /usr/local/php7/etc/
Installing PHP FPM man page: /usr/local/php7/php/man/man8/
Installing PHP FPM status page: /usr/local/php7/php/php/fpm/
Installing phpdbg binary: /usr/local/php7/bin/
Installing phpdbg man page: /usr/local/php7/php/man/man1/
Installing PHP CGI binary: /usr/local/php7/bin/
Installing PHP CGI man page: /usr/local/php7/php/man/man1/
Installing build environment: /usr/local/php7/lib/php/build/
Installing header files: /usr/local/php7/include/php/
Installing helper programs: /usr/local/php7/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/php7/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /usr/local/php7/lib/php/
[PEAR] Archive_Tar - already installed: 1.4.14
[PEAR] Console_Getopt - already installed: 1.4.3
[PEAR] Structures_Graph- already installed: 1.1.1
[PEAR] XML_Util - already installed: 1.4.5
[PEAR] PEAR - already installed: 1.10.13
Warning! a PEAR user config file already exists from a previous PEAR installation at '/root/.pearrc'. You may probably want to remove it.
Wrote PEAR system config file at: /usr/local/php7/etc/pear.conf
You may want to add: /usr/local/php7/lib/php to your php.ini include_path
/opt/softwares/php-7.4.23/build/shtool install -c ext/phar/phar.phar /usr/local/php7/bin/phar.phar
ln -s -f phar.phar /usr/local/php7/bin/phar
Installing PDO headers: /usr/local/php7/include/php/ext/pdo/
[root@vstat-web php-7.4.23]# /usr/local/php7/bin/php --ini
Configuration File (php.ini) Path: /usr/local/php7/etc
Loaded Configuration File: (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
// 配置php-fpm
cp php.ini-production /etc/php.ini
cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
启动php-fpm
groupadd www
useradd -g www www
/etc/init.d/php-fpm start
或者
service php-fpm start
// PECL config
#!/bin/bash
update-alternatives --set php /usr/local/php7/bin/php
pecl config-set php_ini /etc/php/7.0/cli/php.ini
pecl config-set ext_dir /usr/local/php7/lib/php/extensions/no-debug-non-zts-20190902/
pecl config-set bin_dir /usr/local/php7/bin/
pecl config-set php_bin /usr/local/php7
pecl config-set php_suffix 7.4
// pecl 配置失败,这方法安装不了,直接编译把
instantclient-basic-linux.x64-12.1.0.2.0.zip
instantclient-sdk-linux.x64-12.1.0.2.0.zip
php编译包里ext目录有oci8,如果没有 下载:
cd ext/oci8
ln -s /usr/lib/oracle/instantclient_12_1/libclntsh.so.12.1 /usr/lib/oracle/instantclient_12_1/libclntsh.so
./configure --with-php-config=/usr/local/php7/bin/php-config --with-oci8=shared,instantclient,/usr/lib/oracle/instantclient_12_1
pdo_sqlsrv.so:
wget http://pecl.php.net/get/pdo_sqlsrv-5.9.0.tgz
tar xzvf pdo_sqlsrv-5.9.0.tgz
cd pdo_sqlsrv-5.9.0/
/usr/local/php7/bin/phpize
./configure --with-php-config=/usr/local/php7/bin/php-config
Q: sql.h: No such file or directory
A: yum install unixODBC-devel
mac OS 安装OCI
在Oracle官网下载instant client for os x。 下载 instantclient-basic-macos和 instantclient-sdk-macos两个包
Instant Client for macOS (Intel x86) (oracle.com)
配置环境变量:ORACLE_HOME
ORACLE_HOME=/data/tools/instantclient
使用上面的方法 无法安装
下载源码编译安装吧:
> /data/tools/instantclient/instantclient_12_1 这个目录是instantclient (basic和sdk解压缩的目录,两个包下载下来后直接解压缩就好了)
下载:oci8-2.2.0: wget https://pecl.php.net/get/oci8-2.2.0.tgz
tar xzvf oci8-2.2.0.targs
cd oci8-2.2.0
phpize
./configure --with-php-config=php-config --with-oci8=shared,instantclient,/data/tools/instantclient/instantclient_12_1
ln -s /data/tools/instantclient/instantclient_12_1/libclntsh.dylib.12.1 /data/tools/instantclient/instantclient_12_1/libclntsh.dylib
由于需要Mac OS 安装mssql 扩展同上:
wget [http://pecl.php.net/get/pdo_sqlsrv-5.9.0.tgz](http://pecl.php.net/get/pdo_sqlsrv-5.9.0.tgz)
tar xzvf pdo_sqlsrv-5.9.0.tgz
cd pdo_sqlsrv-5.9.0/
/usr/local/php7/bin/phpize
./configure --with-php-config=/usr/local/php7/bin/php-config
PHP7.4 安装部分参考: centos7 编译安装 php7.4 - bobiscool - 博客园 (cnblogs.com)