Copiado del post de Daniel escrito en el marco de sus proyectos aqui : http://danielphp.wordpress.com/install-oracle-express-and-php-oci8-on-ubuntu-9-10/
(Requirements: PHP 5 and Apache 2 already installed)
Go to Oracle website, and download the following files: (You are gonna need to register an account with Oracle to be able to download the files, just do it, its free)
- oracle-xe-universal_10.2.0.1-1.0_i386.deb
- Oracle instant client basic 11.2.0.1, zip package
- Oracle instant client sdk 11.2.0.1, zip package
/etc/init.d/oracle-xe configureyou will see something like this:
Specify the HTTP port that will be used for Oracle Application Express [8080]: Specify a port that will be used for the database listener [1521]: /* Specify a password to be used for database accounts. Note that the same password will be used for SYS and SYSTEM. Oracle recommends the use of different passwords for each database account. This can be done after initial configuration: */ Confirm the password: (* make sure you remember this password *) Do you want Oracle Database 10g Express Edition to be started on boot (y/n) [y]: yAt this point you can open Firefox,enter http://127.0.0.1:8080/apex, login as ’system’ with the ‘password’ you created during the install, and you should see the XE homepage. Now put the other 2 files in /tmp. Then do the following:
cd /tmp/ unzip oracle-instantclient-basic-11.2.0.1.i386.zip mv instantclient_11_2 /opt/ unzip oracle-instantclient-devel-11.2.0.1.i386.zip mv instantclient_11_2/sdk /opt/instantclient_11_2/ export ORACLE_HOME=/opt/instantclient_11_2/ ln -s /opt/instantclient_11_2/libclntsh.so.11.1 /opt/instantclient_11_2//libclntsh.so ln -s /opt/instantclient_11_2/libocci.so.11.1 /opt/instantclient_11_2//libocci.so ln -s /opt/instantclient_11_2/ /opt/instantclient_11_2/libthen install the packages php-dev and php-pear, and go to console and type the following:
pecl download OCI8 tar xzvf oci8-1.3.5.tgz cd ../oci8-1.3.5 phpize ./configure --with-oci8=instantclient,/opt/instantclient_11_2/ make sudo make installAt that point, the libraries have been built but are not used by PHP. In this extent, you must add it at the bottom of php.ini files “/etc/php5/apache2/php.ini” (and if you got CLI installed also add to this file “/etc/php5/cli/php.ini”):
extension = oci8.soEdit your /etc/bash.bashrc file to include the lines:
ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server PATH=$PATH:$ORACLE_HOME/bin export ORACLE_HOME export ORACLE_SID=XE export PATHNow just do a logout and login (this will restart the env variables, if you are advanced user then just do it your way). restart apache.Finally try this php example:
$ora_conn = oci_connect('system',$your_password,'127.0.0.1/XE'); // error handling if (!$ora_conn){ // do the following if it fails $ora_conn_erno = oci_error(); echo ($ora_conn_erno['message']."n"); oci_close($ora_conn); } else { // if it doesn't fail it will proceed with the rest of the script echo "Connection Succesfuln"; oci_close($ora_conn); }If it shows “Connection Succesful” then you are done. Congratulations. Additional Notes:
- this was tested with PHP 5.2.10 ,Apache/2.2.12 and Ubuntu 9.10 Karmic Koala
- check that the ORACLE_HOME path exist just in case you have problems.
- if the version of instantclient you download is different to 11.2, just change every reference to 11_2 for your new version.