사용자 도구

사이트 도구


develop:php:oci8_install

Enabling the php oci8

APT install

  1. php 관련 패키지를 설치한다.
    # apt-get install build-essential libaio1 
  2. php 패키지를 설치 (ubuntu 18.04 )
    # apt-get install libapache2-mod-php7.2 php7.2 php7.2-dev apache2


    ubuntu 16.04 일 경우에는 아래의 명령어로 설치

    # apt-get install libapache2-mod-php7.0 php7.0 php7.0-dev apache2

Oracle Installed

Oracle Server

ORACLE_BASE /usr/local/instantclient_11_2
ORACLE_HOME /usr/local/instantclient_11_2
LD_LIBRARY_PATH /usr/local/instantclient_11_2

Oracle Instant

  1. bash 설정
    # vi /etc/bash_completion.d/oracle
    export ORACLE_BASE="/usr/local/instantclient_11_2"
    export ORACLE_HOME="/usr/local/instantclient_11_2"
    export LD_LIBRARY_PATH="/usr/local/instantclient_11_2"
  2. /etc/environment
    ...
    LD_LIBRARY_PATH=/usr/local/instantclient_11_2:$LD_LIBRARY_PATH
  3. echo /usr/local/instantclient_11_2 > /etc/ld.so.conf.d/oracle-instantclient.conf

OCI8 Install

  1. http://pecl.php.net/package/oci8 에서 최신버젼을 다운로드 받는다.
    $ wget http://pecl.php.net/get/oci8-2.1.8.tgz
  2. 압축을 해제한다.
    $ tar xvfz oci8-2.1.8.tgz
  3. 소스경로로 이동한다.
    $ cd oci8-2.1.8/
  4. PHP 확장모듈을 위한 빌드환경을 만들기 위해 phpize 를 실행한다.
    $ phpize
  5. libclntsh.so 경로를 확인한다.
    # oracle server 설정
    $ ls $ORACLE_HOME/lib/libclntsh.so
    /u01/app/oracle/product/10.2.0/lib/libclntsh.so
    or
    # oracle instant client 설정
    $ ls $ORACLE_HOME/libclntsh.so
    /usr/local/instantclient_11_2/libclntsh.so

    링크가 제대로 존재하는지 확인

    $ cd $ORACLE_HOME
    $ ln -s /usr/local/instantclient_11_2/libocci.so.11.1 libocci.so
    $ ln -s /usr/local/instantclient_11_2/libclntsh.so.11.1 libclntsh.so
  6. 환경설정을 맞춰서 컴파일을 한다.
    –with-oci8 에 상황에 맞게 shared 와 instantclient 를 붙여준다.
    $ ./configure --with-oci8=$ORACLE_HOME (default)
    $ ./configure --with-oci8=instantclient,$ORACLE_HOME
    $ ./configure --with-oci8=shared,instantclient,$ORACLE_HOME

    –with-oci8=instantclient,$ORACLE_HOME 으로 진행

  7. make
    $ make
  8. make install 를 실행한다.
    root가 아닐 경우 퍼미션 에러가 날 수 있다, 이때에는 sudo 를 같이 써준다.
    $ make install
    $ sudo make install
    
    [sudo] password for starlits: 
    /bin/bash /home/starlits/src/opensources/oci8-2.0.8/libtool --mode=install cp ./oci8.la /home/starlits/src/opensources/oci8-2.0.8/modules
    libtool: install: cp ./.libs/oci8.so /home/starlits/src/opensources/oci8-2.0.8/modules/oci8.so
    libtool: install: cp ./.libs/oci8.lai /home/starlits/src/opensources/oci8-2.0.8/modules/oci8.la
    libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/sbin" ldconfig -n /home/starlits/src/opensources/oci8-2.0.8/modules
    ----------------------------------------------------------------------
    Libraries have been installed in:
       /home/starlits/src/opensources/oci8-2.0.8/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.
    ----------------------------------------------------------------------
    Installing shared extensions:     /usr/lib/php5/20090626+lfs/
  9. /etc/php/7.2/apache2/php.ini 에서 oci8을 확인한다.
    # vi /etc/php/7.2/apache2/php.ini
    ...
    ;extension=oci8_12c  ; Use with Oracle Database 12c Instant Client
    ;extension=odbc
    ;extension=openssl
    ;extension=pdo_firebird
    ;extension=pdo_mysql
    ;extension=pdo_oci
    ;extension=pdo_odbc
    ;extension=pdo_pgsql
    ;extension=pdo_sqlite
    ;extension=pgsql
    ;extension=shmop
    extension=oci8
    ...
  10. /etc/php/7.2/cli/php.ini 에서 oci8을 확인한다.
    cli 설정시 php -m 으로 설치모듈을 확인할 수 있다.
    # vi /etc/php/7.2/cli/php.ini
    ...
    extension=oci8
    ..
    # php -m | grep oci8
    oci8
  11. apache2 재시작
  12. phpinfo 로 확인
develop/php/oci8_install.txt · 마지막으로 수정됨: 2020/03/08 15:41 저자 starlits