Skip to content

Instantly share code, notes, and snippets.

@neves
Last active September 26, 2018 00:59
Show Gist options
  • Save neves/fa96b3ed7881c5b7832fdb39a305d7bb to your computer and use it in GitHub Desktop.
Save neves/fa96b3ed7881c5b7832fdb39a305d7bb to your computer and use it in GitHub Desktop.
# install oracle extension to php 5.6 and Oracle Express 11g on ubuntu 16.04
apt-get update
# to install rpm on ubuntu
apt-get install -qy alien
alien -vi oracle/oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
alien -vi oracle/oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
# add php 5.6 to ubuntu 16
apt-get install -qy software-properties-common
printf "\n" | LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
apt-get update
apt-get install -qy php5.6-cli php-pear php5.6-dev php5.6-xml libaio1
printf "\n" | pecl install oci8-1.4.10
echo 'extension=oci8.so' >> /etc/php/5.6/cli/php.ini
cat <<EOF > oracle.php
<?php
$r = oci_connect('system', 'oracle', 'localhost:49161/XE');
var_dump($r);
$stid = oci_parse($r, 'SELECT sysdate FROM dual');
$sql = oci_execute($stid);
var_dump($sql);
$row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS);
var_dump($row);
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment