Created
May 17, 2018 16:19
-
-
Save cbj4074/fa761f60b6f8db431539d76ebfba828e to your computer and use it in GitHub Desktop.
Shell script to install Oracle OCI8 extension for PHP on Ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo 'Installing Oracle Instant Client...' | |
export DEBIAN_FRONTEND=noninteractive | |
apt-get -yq install libaio1 unzip php-dev | |
# See: http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html#ic_x64_inst | |
client_version='12_2' | |
devel_pkg='instantclient-sdk-linux.x64-12.2.0.1.0.zip' | |
basic_pkg='instantclient-basic-linux.x64-12.2.0.1.0.zip' | |
src_dir='/opt/oracle' | |
mkdir -p "$src_dir" && chmod 755 "$src_dir" | |
cd /vagrant/scripts-custom/resources/oracle-instant-client | |
unzip -o "./$devel_pkg" -d "$src_dir" | |
unzip -o "./$basic_pkg" -d "$src_dir" | |
cd "$src_dir/instantclient_$client_version" | |
ln -sf libclntsh.so.12.1 libclntsh.so | |
ln -sf libocci.so.12.1 libocci.so | |
# Required to make this value available NOW. | |
export LD_LIBRARY_PATH={$src_dir}/instantclient_$client_version:$LD_LIBRARY_PATH | |
# Required to make this value available persistently. | |
echo "LD_LIBRARY_PATH=\"$src_dir/instantclient_$client_version\"" >> /etc/environment | |
# Required to make this value available to NGINX and therefore PHP-FPM. | |
echo "fastcgi_param LD_LIBRARY_PATH '$src_dir/instantclient_$client_version';" >> /etc/nginx/conf.d/php.conf | |
cd /usr/local/src | |
version='2.1.8' | |
wget -q "https://pecl.php.net/get/oci8-$version.tgz" -O "./oci8-$version.tgz" | |
tar zxvf "oci8-$version.tgz" | |
cd "oci8-$version" | |
# PHP 5.x is not supported with this version of the driver! | |
phpize7.0 | |
./configure --with-php-config=/usr/bin/php-config7.0 --with-oci8=instantclient,$src_dir/instantclient_$client_version >/dev/null 2>&1 | |
make clean > /dev/null | |
make >/dev/null 2>&1 | |
sudo make install | |
sudo chmod 644 /usr/lib/php/20151012/oci8.so | |
sudo bash -c "echo 'extension=oci8.so' > /etc/php/7.0/mods-available/oci8.ini" | |
sudo ln -s /etc/php/7.0/mods-available/oci8.ini /etc/php/7.0/cli/conf.d/20-oci8.ini | |
sudo ln -s /etc/php/7.0/mods-available/oci8.ini /etc/php/7.0/fpm/conf.d/20-oci8.ini | |
sudo service php7.0-fpm restart | |
phpize7.1 | |
./configure --with-php-config=/usr/bin/php-config7.1 --with-oci8=instantclient,$src_dir/instantclient_$client_version >/dev/null 2>&1 | |
make clean > /dev/null | |
make >/dev/null 2>&1 | |
sudo make install | |
sudo chmod 644 /usr/lib/php/20160303/oci8.so | |
sudo bash -c "echo 'extension=oci8.so' > /etc/php/7.1/mods-available/oci8.ini" | |
sudo ln -s /etc/php/7.1/mods-available/oci8.ini /etc/php/7.1/cli/conf.d/20-oci8.ini | |
sudo ln -s /etc/php/7.1/mods-available/oci8.ini /etc/php/7.1/fpm/conf.d/20-oci8.ini | |
sudo service php7.1-fpm restart | |
phpize7.2 | |
./configure --with-php-config=/usr/bin/php-config7.2 --with-oci8=instantclient,$src_dir/instantclient_$client_version >/dev/null 2>&1 | |
make clean > /dev/null | |
make >/dev/null 2>&1 | |
sudo make install | |
sudo chmod 644 /usr/lib/php/20170718/oci8.so | |
sudo bash -c "echo 'extension=oci8.so' > /etc/php/7.2/mods-available/oci8.ini" | |
sudo ln -s /etc/php/7.2/mods-available/oci8.ini /etc/php/7.2/cli/conf.d/20-oci8.ini | |
sudo ln -s /etc/php/7.2/mods-available/oci8.ini /etc/php/7.2/fpm/conf.d/20-oci8.ini | |
sudo service php7.2-fpm restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment