Title: Installing Oracle Instant Client and making it work with PHP Post by: Gena01 on October 31, 2007, 12:27:35 pm This is something that I wanted to post up for a while, because this is rather simple stuff and yet it took me a while to put this whole thing together for my own use/setup. It's also something that got some people interested and they asked me to post this up. So this post is for Maggie Nelson (http://www.objectivelyoriented.com/) who is an active PHP and Oracle advocate.
These instructions are for Linux since this is what I use. I am also using Mandriva 2007.1 and will be using RPM packages where available and will mentioned some things specific to Mandriva. Setup consists of two parts: 1. Installing Oracle Instant Client on Linux 2. Getting and compiling oci8 extension for PHP. So let's begin. Installing Oracle Instant Client on Linux: 1. Download the Oracle Instant Client for Linux rpms from http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html (http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html). The files that I am using and that you will need are: Code: oracle-instantclient-sqlplus-10.2.0.3-1 Code: sudo rpm -ivh oracle-instantclient-* 3. You need to be root at this point: Code: sudo bash 5. You will also need to grab a copy of tnsnames.ora file either from your Oracle DBA or from another system. Code: copy tnsnames.ora /etc/oracle Code: vi /etc/profile.d/oracle.sh Code:
Code: export Getting and compiling oci8 extension for PHP: 1. pear download pecl/oci8 2. tar -xzvf oci8-1.2.4.tgz 3. cd oci8-1.2.4 4. phpize (php4ize for php4 support, it seems Mandriva names these binaries differently for php4) 5. ./configure --with-oci8=instantclient,/usr/lib/oracle/10.2.0.3/client/lib 6. make 7. sudo make install Now become root user (sudo bash) 8. Create a file called /etc/php.d/999_oci.ini and place the following line there: Code: extension=oci8.so Code: ### 11. And you are done. Pull up a page that calls phpinfo() and confirm that oci8 is loaded in apache and that the environment variables are setup properly. You can also do "php -m" to see of php cli loads the module as well. I hope that this is very informative and that I didn't miss anything. If there's something that I missed or there's an error somewhere then please let me know and I will correct it. UPDATE: Make sure you have php "dev" package installed so that you can compile PHP extension(s). UPDATE 2: I have posted updated instructions regarding Oracle Instant Client 11g and building Pecl OCI8 with 1 line (http://www.gena01.com/forum/gena01_blog/installing_oracle_instant_client_11g_and_pecl_oci8-t193.0.html) Gena01 |