Diff for "PHPOracle"


Differences between revisions 1 and 19 (spanning 18 versions)
Revision 1 as of 2006-07-10 03:44:00
Size: 1585
Editor: 202
Comment:
Revision 19 as of 2014-01-03 04:33:00
Size: 3136
Editor: 202
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
To be able to access Oracle databases from PHP, you will need to have the Oracle OCI library installed in your machine. To be able to access Oracle databases from PHP, you will need to have PHP compiled / linked with the Oracle OCI (oci8) library.
Line 3: Line 3:
There are two ways to get this library: You could use the [[http://www.oracle.com/technology/tech/php/zendcore/index.html|pre-built PHP 5 from Zend]] or there are two other ways to get PHP working with OCI8:
Line 16: Line 16:
Tested Environment: Tested Environments:
Line 18: Line 18:
Ubuntu Server 6.06 LTS
Oracle Instant Client 10.2.0.2
 * Ubuntu Server 10.04 LTS
 * Oracle Instant Client 11.2

 * Ubuntu 11
.04 x64
 * Oracle Instant Client 11
.2
Line 25: Line 28:
sudo apt-get install php5-dev php-pear sudo apt-get install php5-dev php-pear libaio1
Line 28: Line 31:
Also download the Oracle Instant Client
http://www.oracle.com/technology/tech/oci/instantclient/index.html
Instant Client installation requires some environment variables to be able to see the library folder. Edit /etc/environment and add at the end:
Line 31: Line 33:
You will need the Basic (34MB) and SDK (600K). The Basic Lite version does not work. {{{
# Oracle Instant Client
LD_LIBRARY_PATH="/usr/local/lib/instantclient_11_2"
TNS_ADMIN="/usr/local/lib/instantclient_11_2"
ORACLE_BASE="/usr/local/lib/instantclient_11_2"
ORACLE_HOME=$ORACLE_BASE
}}}

Then download the [[http://www.oracle.com/technology/tech/oci/instantclient/index.html|Oracle Instant Client]] from Oracle ([[http://www.oracle.com/technetwork/topics/linuxsoft-082809.html|x86]] or [[http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html|x86-64]]) (you will need to create an account).

You will need the Basic (48MB) and SDK (600K). The Basic Lite version does not work.
Line 37: Line 49:
cd instantclient_10_2
sudo ln -s libclntsh.so.10.1 libclntsh.so
cd instantclient_11_2
sudo ln -s libclntsh.so.11.1 libclntsh.so
Line 41: Line 53:
The symbolic link is needed by during the compilation step later. The symbolic link is needed during the compilation step later.
Line 50: Line 62:
instantclient,/usr/local/lib/oracle_10_2 instantclient,/usr/local/lib/instantclient_11_2
Line 52: Line 64:

You will be prompted also for the ORACLE_HOME location, type 'all', accept and then insert:

{{{
instantclient,/usr/local/lib/instantclient_11_2
}}}



== PHP5 Instructions ==

You should now create a new oci8.ini file which will be included when loading php.ini (Editing the php.ini is discouraged):
{{{
nano /etc/php5/conf.d/oci8.ini
}}}
this will create a blank file; add to this file:
{{{
extension=oci8.so
}}}

In Ubuntu 13.10, you should create a new oci8.ini in:
{{{
nano /etc/php5/apache2/conf.d/oci8.ini
}}}
this will create a blank file. Then add to this file:
{{{
extension=oci8.so
}}}


== Old Instructions (Maybe PHP4) ==
Line 56: Line 99:
extension = oci8.so extension=oci8.so
Line 65: Line 108:
Check <?php echo phpinfo() ?> to verify if the OCI8 module is available. or
{{{
sudo service apache2 restart
}}}


Check {{{<?php echo phpinfo() ?>}}} to verify if the oci8 module is available.
Line 68: Line 117:

* [[http://www.orafaq.com/wiki/PHP|Oracle PHP Wiki]]

To be able to access Oracle databases from PHP, you will need to have PHP compiled / linked with the Oracle OCI (oci8) library.

You could use the pre-built PHP 5 from Zend or there are two other ways to get PHP working with OCI8:

  1. Install the Oracle Database [Oracle10g] [Oracle9i]
  2. Install Oracle Instant Client

If your Oracle database is in another machine, the Oracle Instant Client is a smaller install.

PHP using Oracle Database Server

TODO

PHP using Oracle Instant Client

Tested Environments:

  • Ubuntu Server 10.04 LTS
  • Oracle Instant Client 11.2
  • Ubuntu 11.04 x64
  • Oracle Instant Client 11.2

Prerequisites:

sudo apt-get install build-essential
sudo apt-get install php5-dev php-pear libaio1

Instant Client installation requires some environment variables to be able to see the library folder. Edit /etc/environment and add at the end:

# Oracle Instant Client
LD_LIBRARY_PATH="/usr/local/lib/instantclient_11_2"
TNS_ADMIN="/usr/local/lib/instantclient_11_2"
ORACLE_BASE="/usr/local/lib/instantclient_11_2"
ORACLE_HOME=$ORACLE_BASE

Then download the Oracle Instant Client from Oracle (x86 or x86-64) (you will need to create an account).

You will need the Basic (48MB) and SDK (600K). The Basic Lite version does not work.

cd /usr/local/lib
sudo unzip <location-of-instant-client-basic>
sudo unzip <location-of-instant-client-sdk>
cd instantclient_11_2
sudo ln -s libclntsh.so.11.1 libclntsh.so

The symbolic link is needed during the compilation step later.

sudo pecl install oci8

You will be prompted for the location of the library:

instantclient,/usr/local/lib/instantclient_11_2

You will be prompted also for the ORACLE_HOME location, type 'all', accept and then insert:

instantclient,/usr/local/lib/instantclient_11_2

PHP5 Instructions

You should now create a new oci8.ini file which will be included when loading php.ini (Editing the php.ini is discouraged):

nano /etc/php5/conf.d/oci8.ini

this will create a blank file; add to this file:

extension=oci8.so

In Ubuntu 13.10, you should create a new oci8.ini in:

nano /etc/php5/apache2/conf.d/oci8.ini

this will create a blank file. Then add to this file:

extension=oci8.so

Old Instructions (Maybe PHP4)

If successful, you may now add the following line at the bottom of php.ini

extension=oci8.so

The php.ini is found in 2 places: /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini

sudo /etc/init.d/apache2 reload

or

sudo service apache2 restart

Check <?php echo phpinfo() ?> to verify if the oci8 module is available.

Further Reading

* Oracle PHP Wiki

PHPOracle (last edited 2014-01-03 04:33:00 by 202)