Steps to get Oracle working with php
The following steps were followed to get Oracle OCI connectivity with PHP
Considerations
The full install of Oracle XE on Ubuntu server should have been the potential candidate for getting the OCI going, however it did not quite work as expected so Oracle Instant Client was installed
Instant Client
- Instant Client Downloads for Linux x86-64. The file location was here. Choose the correct version depending on your O/S. There was four files and all four were downloaded although only two were required
- Instant Client Package - Basic (required)
- Instant Client Package - JDBC Supplement (optional)
- Instant Client Package - SQL*Plus (optional)
- Instant Client Package - SDK (required)
- Instant Client Package - ODBC (optional)
- Downloaded and extracted the files to /opt/oracle/instantclient_10_2
- Created a Oracle Instant Client user oraic and set the following in .profile
- export ORACLE_HOME=/opt/oracle/instantclient_10_2
- export LD_LIBRARY_PATH=$ORACLE_HOME
- export TNS_ADMIN=$ORACLE_HOME
- export PATH=“$ORACLE_HOME:$PATH”
- At this point you can test this install by connecting to a remote or local database
Setting up PHP for Oracle OCI
To get php working with oracle the following needs to be done
- apt-get install php5-dev
- apt-get install build-essential (may not be required)
- pecl install oci8 (see full log here) Will need to specify instant client home location
- Add extension=oci8.so to php.ini
- Update /etc/apache2/envvars to include ORACLE_HOME and other variables (same as .profile except PATH)
- Create/Update tnsnames.ora and put in ORACLE_HOME (set TNS_ADMIN to same as ORACLE_HOME)
- restart apache