Bash script to run "pecl install oci8"

6,312

Solution 1

My solution was to run the following command:

export C_INCLUDE_PATH=/usr/include/oracle/11.2/client

and restart:

pecl insatlla oci8

Solution 2

Typically for this kind of installation you can echo in the parameters you want to set. I wrapped the entire statement so that it can be executed with sudo permissions

sudo sh -c "echo 'instantclient,/opt/oracle/instantclient' | pecl install oci8"

Solution 3

I did not really find a general purpose solution to this problem. What ended up working in my specific scenario (provisioning via Vagrant) was using a Puppet manifest for this specific provisioning step, which was easy since you just need to specify it in the Vagrant configuration after the Shell provisioner:

"pecl-install-oci8":
    command => "pecl install oci8",
    user => root,
    timeout => 0,
    tries   => 5,
    unless => "/usr/bin/php -m | grep -c oci8";

For some reason that I have yet to figure out, puppet installs oci8 without issue.

And when I'd done this I ported my whole script to a Puppet manifest, but that is off-topic.

Share:
6,312

Related videos on Youtube

Hadeer Zayat
Author by

Hadeer Zayat

Updated on September 18, 2022

Comments

  • Hadeer Zayat
    Hadeer Zayat over 1 year

    I am trying to create shell script that will do the initial provisioning of a vagrant vm (running Ubuntu 12.04). Everything (installing php, apache, oracle instantclient, etc,) works fine, except for the last step - installing the php oci8 extension:

    pecl install oci8
    

    When I run this command manually (with sudo prefix) it works fine. But when the script runs this command it fails like this:

    running: make
    /bin/bash /tmp/pear/temp/pear-build-rootG74SsU/oci8-2.0.6/libtool --mode=compile cc  -I. -I/tmp/pear/temp/oci8 -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootG74SsU/oci8-2.0.6/include -I/tmp/pear/temp/pear-build-rootG74SsU/oci8-2.0.6/main -I/tmp/pear/temp/oci8 -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/temp/oci8/oci8.c -o oci8.lo
    libtool: compile:  cc -I. -I/tmp/pear/temp/oci8 -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootG74SsU/oci8-2.0.6/include -I/tmp/pear/temp/pear-build-rootG74SsU/oci8-2.0.6/main -I/tmp/pear/temp/oci8 -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/oci8/oci8.c  -fPIC -DPIC -o .libs/oci8.o
    In file included from /tmp/pear/temp/oci8/oci8.c:48:0:
    /tmp/pear/temp/oci8/php_oci8_int.h:60:17: fatal error: oci.h: No such file or directory
    compilation terminated.
    make: *** [oci8.lo] Error 1
    ERROR: `make' failed
    

    The pecl script asks for a path in the beginning of the installation, and this is where I think the issue is:

    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] :
    

    For the installation to proceed you either need to supply the ORACLE_HOME directory or press Enter. I have tried the following suggested elsewhere, but it does not work - the line break is missing in the output (compared to when running the pecl command manually) so it does not properly emulate the Enter keystroke:

    printf "\n" | pecl install oci8
    

    Any suggestions on how I can get this to run properly?

    • GnP
      GnP over 10 years
      Could you try echo autodetect | pecl install oci8?
    • Hadeer Zayat
      Hadeer Zayat over 10 years
      @gnp I tried that, and also printf "autodetect", didn't help.