Last active
October 11, 2022 19:59
-
-
Save XenitXTD/5ac2958ce9f692a7127e7ebd4537867a to your computer and use it in GitHub Desktop.
This was an automation configured on the laravel homestead vagrant VM to automate the setup and configuration of the Oracle OCI8 php .so file and installation of the oracle client so that you are able to connect to an oracle database using the Yajra oracle package for laravel, using the homestead after.sh file to setup the required installers et…
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 | |
# If you would like to do some extra provisioning you may | |
# add any commands you wish to this file and they will | |
# be run after the Homestead machine is provisioned. | |
apt-get update | |
# if not installed install it | |
apt-get install unzip | |
mkdir /opt/oracle | |
# Download oracle instantclient-basic-linux.x64 and instantclient-sdk-linux.x64 | |
# (v11.2.x.x.x) from the link provided below and place in the mapped Code folder | |
# http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html | |
# instantclient-basic-linux.x64-12.2.0.1.0 | |
# instantclient-sdk-linux.x64-12.2.0.1.0 | |
cp /home/vagrant/Code/ExtraInstallers/instantclient*12.2* /opt/oracle/ | |
# Download the oracle OCI8 file v2.1.x for php 7 and 1.4.x for php 5.x from | |
# https://pecl.php.net/package/oci8 and place it in the Mapped Code Folder | |
# oci8-2.1.8 | |
cp /home/vagrant/Code/ExtraInstallers/oci8-2.1.8.tgz /home/vagrant/ | |
cd /opt/oracle | |
unzip /opt/oracle/*.zip | |
mv /opt/oracle/instantclient_12_2 /opt/oracle/instantclient | |
rm /opt/oracle/instantclient*.zip | |
chown -R root:www-data /opt/oracle | |
# With UBUNTU 18.04 this libaio1 dependency isnt there by default so include it. | |
apt install php7.2-dev php-pear build-essential libaio1 | |
ln -s /opt/oracle/instantclient/libclntsh.so.12.1 /opt/oracle/instantclient/libclntsh.so | |
ln -s /opt/oracle/instantclient/libocci.so.12.1 /opt/oracle/instantclient/libocci.so | |
#rm -rf /opt/zray/ | |
echo /opt/oracle/instantclient > /etc/ld.so.conf.d/oracle-instantclient.conf | |
ldconfig | |
#cd /home/vagrant | |
# This was manually downloaded from http://pecl.php.net/package/oci8 | |
#tar -xvzf /home/vagrant/oci8-2.1.8.tgz | |
cd /home/vagrant/oci8-2.1.8/ | |
phpize7.2 | |
#configure --with-php-config=/usr/bin/php-config --with-oci8=instantclient,/opt/oracle/instantclient (PECL Install Version) | |
./configure --with-oci8=shared,instantclient,/opt/oracle/instantclient | |
make | |
make install | |
make test | |
#pecl install oci8 | |
rm -rf /home/vagrant/oci8-2.1.8 | |
rm /home/vagrant/oci8-2.1.8.tgz | |
#UPDATE PECL to prevent error | |
#pecl channel-update pecl.php.net | |
#PHP OCI8 Driver | |
#pecl install oci8 | |
#At the prompt | |
# instantclient,/opt/oracle/instantclient' | |
cd /etc/php/7.2/mods-available/ | |
touch /etc/php/7.2/mods-available/oci.ini | |
# create a customer ini in /etc/php/7.2/fpm/conf.d/ like 20-oci8.ini as well as the /etc/php/7.2/cli/conf.d/ | |
# Place the actual oci8.so file in the /usr/lib/php/[LatestDate]/ directory where the other files are stored | |
# these files are aliased using a symbolic link | |
#Putting the cart before the horse here, but it leaves the only interactive part for the end. | |
echo '; configuration for php oci8 module' >> /etc/php/7.2/mods-available/oci.ini | |
echo '; priority=20' >> /etc/php/7.2/mods-available/oci.ini | |
echo 'extension=oci8.so' >> /etc/php/7.2/mods-available/oci.ini | |
#extension=oci8_12c | |
cd /etc/php/7.2/fpm/conf.d/ | |
ln -s /etc/php/7.2/mods-available/oci.ini 20-oci.ini /etc/php/7.2/fpm/conf.d/ | |
cd /etc/php/7.2/cli/conf.d/ | |
ln -s /etc/php/7.2/mods-available/oci.ini 20-oci.ini /etc/php/7.2/cli/conf.d/ | |
echo '' | |
echo '# Oracle Instant Client' >> /etc/environment | |
echo 'export LD_LIBRARY_PATH="/opt/oracle/instantclient"' >> /etc/environment | |
echo 'export TNS_ADMIN="/opt/oracle/instantclient"' >> /etc/environment | |
echo 'export ORACLE_BASE="/opt/oracle/instantclient"' >> /etc/environment | |
echo 'export ORACLE_HOME=$ORACLE_BASE' >> /etc/environment | |
#After | |
service php7.2-fpm restart | |
#rm -rf /opt/zray/ | |
# check if OCI is installed must return oci8 | |
#php-fpm7.1 -m | grep oci8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment