分类: LINUX
2017-02-14 19:05:31
Make sure met the following requirements:
Download the Oracle Instant Client and SDK from . Make sure you choose the correct architecture for your Ubuntu installation (32bit is x86, 64bit is x86_64). You’ll need to upload the files to your server using whatever method suits you.
Create a new folder to store Oracle Instant Client zip files on your server.
mkdir /opt/oracle
Upload the Instant Clients files inside this folder.
Now we need to extract the files.
cd /opt/oracle unzip instantclient-basic-linux-12.1.0.2.0.zip unzip instantclient-sdk-linux-12.1.0.2.0.zip
Next, we need to create a symlink to Instant Client files.
ln -s /opt/oracle/instantclient_12_1/libclntsh.so.12.1 /opt/oracle/instantclient_12_1/libclntsh.so ln -s /opt/oracle/instantclient_12_1/libocci.so.12.1 /opt/oracle/instantclient_12_1/libocci.so
Add the folder to our .
echo /opt/oracle/instantclient_12_1 > /etc/ld.so.conf.d/oracle-instantclient
Update the Dynamic Linker Run-Time Bindings
ldconfig
Done. Now we can proceed to the next part.
To install the OCI8 extension, we need to install some additional package on our server.
Run these command:
apt-get install php-pear php5-dev build-essential libaio1
Once installed, we need to get the OCI8 file.
pecl install oci8-2.0.10
When you are prompted for the Instant Client location, enter the following:
instantclient,/opt/oracle/instantclient_12_1
We need to tell PHP to load the OCI8 extension.
echo "extension = oci8.so" >> /etc/php5/apache2/php.ini echo "extension = oci8.so" >> /etc/php5/cli/php.ini
Restart your apache
/etc/init.d/apache2 restart
Now you can connect to Oracle DBMS from your PHP applications.