If you are planning on using the oracle functions in PHP, you will need to install OCI8. Before you begin you will need to create an account with oracle or have access to the instant client basic install file and sdk file for your linux architecture.
Prerequisites for installing OCI8
- sudo (you will be doing the command line parts as sudo).
- An account on the oracle website so you can download the instant client files.
- A working Apache and PHP installation.
Installing the Oracle Instant Client Files
- Download the Oracle Instant Client for Linux (Both the Basic and SDK versions) from here. Make sure you choose the correct architecture for your Ubuntu installation (32bit is x86, 64bit is x86_64).
- Copy the files just downloaded to your Ubuntu server using scp or the WinSCP application for windows.
- ssh into your ubuntu server using your favorite ssh client
- Install PECL, PHP Development files, Build Essential, Unzip, and the AIO Library
apt-get install php-pear php5-dev build-essential unzip libaio1
- Create the oracle directory
- Move the downloaded files
mv instantclient-* /opt/oracle
- Unzip the files using the unzip command (unzip <filename>)
- Rename the created directory
mv instantclient_11_2 instantclient
- cd into the instant client directory and create the following soft links
ln -s libclntsh.so.11.2 libclntsh.so ln -s libocci.so.11.2 libocci.so
- cd to /opt
- set the permissions on the directory
chown -R root:www-data /opt/oracle
- Add the instant client to the the ld config files
echo /opt/oracle/instantclient > /etc/ld.so.conf.d/oracle-instantclient
- Update the Dynamic Linker Run-Time Bindings
Installing OCI 8 and Configuring Apache
- Install OCI8 using PECL
pecl install 0ci8
- When you are pompted for the client location enter the following:
- Add the extension to the php.ini files
echo extension=oci8.so >> /etc/php5/apache2/php.ini echo extension=oci8.so >> /etc/php5/cli/php.ini
- Restart Apache
- Verify the installation of the OCI8 library by creating a simple phpinfo page.
touch info.php; echo "<?php phpinfo(); ?>" > info.php
- Navigate to the page using your favorite web browser and confirm the OCI8 section is present.