This tutorial assumes that you have already installed
php
and other packages (e.g. php-pdo
)
you normally need. This was also tested with an installation of Oracle 11g Express. I’m not sure
if this will work for higher versions.Dependencies
Development packages
$ sudo yum install php-pear php-devel zlib zlib-devel bc libaio glibc
$ sudo yum groupinstall "Development Tools"
InstantClient
Download Oracle InstantClient RPM files http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html . Put these files in your server. Download the basic and devel packages.- Basic: oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm
- Devel: oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm
$ sudo rpm -ivh oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm
$ sudo rpm -ivh oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm
$ sudo ln -s /usr/include/oracle/11.2/client64 /usr/include/oracle/11.2/client
$ sudo ln -s /usr/lib/oracle/11.2/client64 /usr/lib/oracle/11.2/client
Create a file inside /etc/profile.d
named oracle.sh
and put this as the content:export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib
And run it so we’ll have LD_LIBRARY_PATH
as an environment variable.source /etc/profile.d/oracle.sh
PDO_OCI
Download the PDO_OCI source usingpecl
.$ pecl download PDO_OCI
$ tar -xvf PDO_OCI-1.0.tgz
$ cd PDO_OCI-1.0
Inside the PDO_OCI-1.0
folder, edit the file named config.m4
.Find a pattern like this near line
10
and add these 2 lines:elif test -f $PDO_OCI_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME.11.2; then
PDO_OCI_VERSION=11.2
Find a pattern like this near line 101
and add these lines:11.2)
PHP_ADD_LIBRARY(clntsh, 1, PDO_OCI_SHARED_LIBADD)
;;
Build and install the extension.$ phpize
$ ./configure --with-pdo-oci=instantclient,/usr,11.2
$ make
$ sudo make install
To enable the extension, add a file named pdo_oci.ini
under /etc/php.d
and put this as the content:extension=pdo_oci.so
Validate that it was successfully installed.$ php -i | grep oci
You should see something like this in the output:/etc/php.d/pdo_oci.ini,
PDO drivers => oci, odbc, sqlite
OCI8
Download the OCI8 source usingpear
$ pear download pecl/oci8
$ tar -xvf oci8-1.4.9.tgz
$ cd oci8-1.4.9
Build and install the extension.$ phpize
$ ./configure --with-oci8=shared,instantclient,/usr/lib/oracle/11.2/client64/lib
$ make
$ sudo make install
To enable the extension, add a file named oci8.ini
in /etc/php.d
with this content:extension=oci8.so
Validate that it was successfully installed.$ php -i | grep oci8
You should see something like this:/etc/php.d/oci8.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
Finishing up
Do not forget to restart your web server (e.g. Apache). You can double check withphpinfo()
if
the extensions were successfully installed.
Không có nhận xét nào:
Đăng nhận xét