пятница, 19 декабря 2014 г.

Installing the Oracle Database Extension OCI8 for PHP 5.1.2

1) Возникла необходимость запустить поддержку СУБД Oracle для PHP на старом сервере.

# cat /etc/asplinux-release
ASPLinux release 11.2 (Ladoga)

phpinfo():
PHP Version 5.1.2

# uname -a
Linux ****** 2.6.17-1.2157.1aspsmp #1 SMP Fri Aug 11 03:45:43 EEST 2006 i686 i686 i386 GNU/Linux

Адреса используемых инструкций:
http://www.oracle.com/technetwork/articles/technote-php-instant-084410.html
http://php.net/manual/en/oci8.installation.php


2) Из  http://php.net/manual/en/oci8.requirements.php следует:

The OCI8 1.4 extension is included with PHP 5.3, PHP 5.4 and PHP 5.5. It is also available from » PECL. A newer OCI8 2.0 version is available only from » PECL. OCI8 1.4 requires Oracle 12c, 11g, 10g or 9iR2 client libraries and will install on PHP 4.3.9 onwards. OCI8 2.0 requires Oracle 12c, 11g or 10g client libraries and will install on PHP 5.2 onwards.
Т.е. подходит OCI8 1.4.

Перед установкой OCI8 1.4 необходимо поставить клиент Оракла.

Страница закачки: http://www.oracle.com/technetwork/topics/linuxsoft-082809.html

Загруженные файлы:

# ls -l
total 57540
-rw-r--r--  1 sergei sergei   169248 Дек 19 08:17 oci8-1.4.10.tgz
-rw-r--r--  1 sergei sergei 58066286 Дек 19 08:10 oracle-instantclient11.2-basic-11.2.0.4.0-1.i386.rpm
-rw-r--r--  1 sergei sergei   610198 Дек 19 08:10 oracle-instantclient11.2-devel-11.2.0.4.0-1.i386.rpm

# rpm -Uvh oracle-instantclient11.2-basic-11.2.0.4.0-1.i386.rpm
error: Failed dependencies:
        libaio is needed by oracle-instantclient11.2-basic-11.2.0.4.0-1.i386

# /usr/share/mc/extfs/rpm run /media/asp_linux/ASPLinux/RPMS/libaio-0.3.104-2.i386.rpm INSTALL
Installing ""'/media/asp_linux/ASPLinux/RPMS/libaio-0.3.104-2.i386.rpm'""
Preparing...                ########################################### [100%]
   1:libaio                 ########################################### [100%]

# rpm -Uvh oracle-instantclient11.2-basic-11.2.0.4.0-1.i386.rpm
Preparing...                ########################################### [100%]
   1:oracle-instantclient11.########################################### [100%]

# rpm -Uvh oracle-instantclient11.2-devel-11.2.0.4.0-1.i386.rpm
Preparing...                ########################################### [100%]
   1:oracle-instantclient11.########################################### [100%]

# pecl install oci8-1.4.10.tgz
10 source files, building
running: phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20050922
Zend Extension Api No:   220051025
Please provide the path to the ORACLE_HOME directory. Use 'instantclient,/path/to/instant/client/lib' if you're compiling with Oracle Instant Client [autodetect] :
building in /var/tmp/pear-build-root/oci8-1.4.10
running: /tmp/tmpJvZP88/oci8-1.4.10/configure --with-oci8
checking for egrep... grep -E
checking for a sed that does not truncate output... /bin/sed
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking whether gcc and cc understand -c and -o together... yes
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... i686-redhat-linux-gnu
checking host system type... i686-redhat-linux-gnu
checking target system type... i686-redhat-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext
checking for PHP extension directory... /usr/lib/php/modules
checking for PHP installed headers prefix... /usr/include/php
checking for re2c... no
configure: WARNING: You will need re2c 0.9.11 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for Oracle Database OCI8 support... yes, shared
checking PHP version... 5.1.2, ok
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for long int... yes
checking size of long int... 4
checking checking if we're on a 64-bit platform... no
configure: WARNING: OCI8 extension: ORACLE_HOME is not set, looking for default Oracle Instant Client instead
checking Oracle Instant Client directory... /usr/lib/oracle/11.2/client/lib
checking Oracle Instant Client SDK header directory... /usr/include/oracle/11.2/client
checking Oracle Instant Client library version compatibility... 11.1
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognise dependent libraries... pass_all
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking for g77... no
checking for f77... no
checking for xlf... no
checking for frt... no
checking for pgf77... no
checking for fort77... no
checking for fl32... no
checking for af77... no
checking for f90... no
checking for xlf90... no
checking for pgf90... no
checking for epcf90... no
checking for f95... no
checking for fort... no
checking for xlf95... no
checking for ifc... no
checking for efc... no
checking for pgf95... no
checking for lf95... no
checking for gfortran... no
checking whether we are using the GNU Fortran 77 compiler... no
checking whether  accepts -g... no
checking the maximum length of command line arguments... 32768
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC
checking if gcc PIC flag -fPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
configure: creating libtool
appending configuration tag "CXX" to libtool
checking for ld used by g++... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC
checking if g++ PIC flag -fPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
appending configuration tag "F77" to libtool
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /var/tmp/pear-build-root/oci8-1.4.10/libtool --mode=compile gcc  -I. -I/tmp/tmpJvZP88/oci8-1.4.10 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.4.10/include -I/var/tmp/pear-build-root/oci8-1.4.10/main -I/tmp/tmpJvZP88/oci8-1.4.10 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/oracle/11.2/client  -DHAVE_CONFIG_H  -g -O2   -c /tmp/tmpJvZP88/oci8-1.4.10/oci8.c -o oci8.lo
mkdir .libs
 gcc -I. -I/tmp/tmpJvZP88/oci8-1.4.10 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.4.10/include -I/var/tmp/pear-build-root/oci8-1.4.10/main -I/tmp/tmpJvZP88/oci8-1.4.10 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/oracle/11.2/client -DHAVE_CONFIG_H -g -O2 -c /tmp/tmpJvZP88/oci8-1.4.10/oci8.c  -fPIC -DPIC -o .libs/oci8.o
/bin/sh /var/tmp/pear-build-root/oci8-1.4.10/libtool --mode=compile gcc  -I. -I/tmp/tmpJvZP88/oci8-1.4.10 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.4.10/include -I/var/tmp/pear-build-root/oci8-1.4.10/main -I/tmp/tmpJvZP88/oci8-1.4.10 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/oracle/11.2/client  -DHAVE_CONFIG_H  -g -O2   -c /tmp/tmpJvZP88/oci8-1.4.10/oci8_lob.c -o oci8_lob.lo
 gcc -I. -I/tmp/tmpJvZP88/oci8-1.4.10 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.4.10/include -I/var/tmp/pear-build-root/oci8-1.4.10/main -I/tmp/tmpJvZP88/oci8-1.4.10 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/oracle/11.2/client -DHAVE_CONFIG_H -g -O2 -c /tmp/tmpJvZP88/oci8-1.4.10/oci8_lob.c  -fPIC -DPIC -o .libs/oci8_lob.o
/bin/sh /var/tmp/pear-build-root/oci8-1.4.10/libtool --mode=compile gcc  -I. -I/tmp/tmpJvZP88/oci8-1.4.10 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.4.10/include -I/var/tmp/pear-build-root/oci8-1.4.10/main -I/tmp/tmpJvZP88/oci8-1.4.10 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/oracle/11.2/client  -DHAVE_CONFIG_H  -g -O2   -c /tmp/tmpJvZP88/oci8-1.4.10/oci8_statement.c -o oci8_statement.lo
 gcc -I. -I/tmp/tmpJvZP88/oci8-1.4.10 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.4.10/include -I/var/tmp/pear-build-root/oci8-1.4.10/main -I/tmp/tmpJvZP88/oci8-1.4.10 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/oracle/11.2/client -DHAVE_CONFIG_H -g -O2 -c /tmp/tmpJvZP88/oci8-1.4.10/oci8_statement.c  -fPIC -DPIC -o .libs/oci8_statement.o
/bin/sh /var/tmp/pear-build-root/oci8-1.4.10/libtool --mode=compile gcc  -I. -I/tmp/tmpJvZP88/oci8-1.4.10 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.4.10/include -I/var/tmp/pear-build-root/oci8-1.4.10/main -I/tmp/tmpJvZP88/oci8-1.4.10 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/oracle/11.2/client  -DHAVE_CONFIG_H  -g -O2   -c /tmp/tmpJvZP88/oci8-1.4.10/oci8_collection.c -o oci8_collection.lo
 gcc -I. -I/tmp/tmpJvZP88/oci8-1.4.10 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.4.10/include -I/var/tmp/pear-build-root/oci8-1.4.10/main -I/tmp/tmpJvZP88/oci8-1.4.10 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/oracle/11.2/client -DHAVE_CONFIG_H -g -O2 -c /tmp/tmpJvZP88/oci8-1.4.10/oci8_collection.c  -fPIC -DPIC -o .libs/oci8_collection.o
/bin/sh /var/tmp/pear-build-root/oci8-1.4.10/libtool --mode=compile gcc  -I. -I/tmp/tmpJvZP88/oci8-1.4.10 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.4.10/include -I/var/tmp/pear-build-root/oci8-1.4.10/main -I/tmp/tmpJvZP88/oci8-1.4.10 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/oracle/11.2/client  -DHAVE_CONFIG_H  -g -O2   -c /tmp/tmpJvZP88/oci8-1.4.10/oci8_interface.c -o oci8_interface.lo
 gcc -I. -I/tmp/tmpJvZP88/oci8-1.4.10 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.4.10/include -I/var/tmp/pear-build-root/oci8-1.4.10/main -I/tmp/tmpJvZP88/oci8-1.4.10 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/oracle/11.2/client -DHAVE_CONFIG_H -g -O2 -c /tmp/tmpJvZP88/oci8-1.4.10/oci8_interface.c  -fPIC -DPIC -o .libs/oci8_interface.o
/bin/sh /var/tmp/pear-build-root/oci8-1.4.10/libtool --mode=link gcc -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.4.10/include -I/var/tmp/pear-build-root/oci8-1.4.10/main -I/tmp/tmpJvZP88/oci8-1.4.10 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/oracle/11.2/client  -DHAVE_CONFIG_H  -g -O2   -o oci8.la -export-dynamic -avoid-version -prefer-pic -module -rpath /var/tmp/pear-build-root/oci8-1.4.10/modules  oci8.lo oci8_lob.lo oci8_statement.lo oci8_collection.lo oci8_interface.lo -Wl,-rpath,/usr/lib/oracle/11.2/client/lib -L/usr/lib/oracle/11.2/client/lib -lclntsh
gcc -shared  .libs/oci8.o .libs/oci8_lob.o .libs/oci8_statement.o .libs/oci8_collection.o .libs/oci8_interface.o  -L/usr/lib/oracle/11.2/client/lib -lclntsh  -Wl,-rpath -Wl,/usr/lib/oracle/11.2/client/lib -Wl,-soname -Wl,oci8.so -o .libs/oci8.so
creating oci8.la
(cd .libs && rm -f oci8.la && ln -s ../oci8.la oci8.la)
/bin/sh /var/tmp/pear-build-root/oci8-1.4.10/libtool --mode=install cp ./oci8.la /var/tmp/pear-build-root/oci8-1.4.10/modules
cp ./.libs/oci8.so /var/tmp/pear-build-root/oci8-1.4.10/modules/oci8.so
cp ./.libs/oci8.lai /var/tmp/pear-build-root/oci8-1.4.10/modules/oci8.la
PATH="$PATH:/sbin" ldconfig -n /var/tmp/pear-build-root/oci8-1.4.10/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /var/tmp/pear-build-root/oci8-1.4.10/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.
(It is safe to ignore warnings about tempnam and tmpnam).

running: make INSTALL_ROOT="/var/tmp/pear-build-root/install-oci8-1.4.10" install
Installing shared extensions:     /var/tmp/pear-build-root/install-oci8-1.4.10/usr/lib/php/modules/
running: find "/var/tmp/pear-build-root/install-oci8-1.4.10" -ls
17006939    4 drwxr-xr-x   3 root     root         4096 Дек 19 08:22 /var/tmp/pear-build-root/install-oci8-1.4.10
17006968    4 drwxr-xr-x   3 root     root         4096 Дек 19 08:22 /var/tmp/pear-build-root/install-oci8-1.4.10/usr
17006969    4 drwxr-xr-x   3 root     root         4096 Дек 19 08:22 /var/tmp/pear-build-root/install-oci8-1.4.10/usr/lib
17006970    4 drwxr-xr-x   3 root     root         4096 Дек 19 08:22 /var/tmp/pear-build-root/install-oci8-1.4.10/usr/lib/php
17006971    4 drwxr-xr-x   2 root     root         4096 Дек 19 08:22 /var/tmp/pear-build-root/install-oci8-1.4.10/usr/lib/php/modules
17006967  396 -rwxr-xr-x   1 root     root       398738 Дек 19 08:22 /var/tmp/pear-build-root/install-oci8-1.4.10/usr/lib/php/modules/oci8.so

Build process completed successfully
Installing '/var/tmp/pear-build-root/install-oci8-1.4.10//usr/lib/php/modules/oci8.so'
install ok: channel://pecl.php.net/oci8-1.4.10
You should add "extension=oci8.so" to php.ini


3) Have edited php.ini and added extension=oci8.so.

# pwd
/usr/lib/php/modules

# ls o*
oci8.so  odbc.so


4) Have added /usr/lib/oracle/11.2/client/lib/ to /etc/ld.so.conf.


5) # service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]


6) phpinfo() shows:

oci8
OCI8 Support     enabled
Version     1.4.10
Revision     $Id: 44bfa713983a99b3e59477f6532e5fb51b6dee94 $
Active Persistent Connections     0
Active Connections     0
Oracle Run-time Client Library Version     11.2.0.4.0
Oracle Instant Client Version     11.2
Temporary Lob support     enabled
Collections support     enabled

Directive    Local Value    Master Value
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

1 комментарий:

  1. 1) Need json_decode() for php-5.1.2.
    From http://php.net/manual/en/function.json-decode.php:
    (PHP 5 >= 5.2.0, PECL json >= 1.2.0)

    2) Download json-1.2.1.tgz from http://pecl.php.net/package/json.

    3) # pecl install json-1.2.1.tgz
    ...
    Build process completed successfully
    Installing '/var/tmp/pear-build-root/install-json-1.2.1//usr/lib/php/modules/json.so'

    # service httpd restart
    Stopping httpd: [ OK ]
    Starting httpd: [ OK ]

    4) phpinfo():
    json
    json support enabled
    json version 1.2.1

    ОтветитьУдалить