Building Apache with PHP, MySQL, OCI8 instant client support

Author:    Nayyar Ahmad

Contact:    nayyares AT gmail DOT com  |  nayyar.ahmad AT cilix DOT co DOT mz

Homepage:  www.cbtcandy.org  

Dedication:   To Babu, in his loving memories.

Preface: 

There are many howtos on building Apache with PHP, MYSQL support, but it is very rare to find some document on OCI8 support with Apache Build, recently I was building a web server in my data center and I was really in trouble when I was searching some installation document, there are few documents , but most of them are using either RPM version of packages or they are missing some of the essential steps. I am trying to write a howto that will help you to at least understand the installation with step-by-step method.

 Plateform:

I am using IBM x system x86_64 bit server with RHEL 4 Update Level 4.

So it begins :

1.Download Oracle Instant Client.

First of all you have to download Oracle Instant Client, here is the link to download it, I am downloading for Linux x86_64, you can adjust according to your hardware.

Here is the link where you can find exact Installer for your hardware.

http://www.oracle.com/technology/software/tech/oci/instantclient/index.html

As I am doing it on Linux x86_64, so i will use following link:

http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxx86_64soft.html

Here you have to download following packges.

1. instantclient-basic-linux-x86-64-10.2.0.2-20060228.zip

2. instantclient-sqlplus-linux-x86-64-10.2.0.2-20060228.zip

3. instantclient-sdk-linux-x86-64-10.2.0.2-20060228.zip

After downloading to your local directory you have to unzip them, as:

$ cd $HOME

assuming you have downloaded in your user home.

$ unzip instantclient-basic-linux-x86-64-10.2.0.2-20060228.zip
$ unzip instantclient-basic-linux-x86-64-10.2.0.2-20060228.zip
$ unzip instantclient-sdk-linux-x86-64-10.2.0.2-20060228.zip

These will unzip to $HOME/instantclient_10_2.

Create the client library symbolic link:

$ ln -s $HOME/instantclient_10_2/libclntsh.so.10.1 $HOME/instantclient_10_2/libclntsh.so

2. Setting up enviroment:

If you are installing all this from oracle user who is suppose to be owner of your database server then you have to make changes in oracle user .bash_profile, it is most likely that you have DB Server and Apache on same server then you might have set some of the variables otherwise you have to write them in oracle .bash_profile, but some time you may have a situation where your Web Server i.e. Apache Server is seperate then Oracle DB Server, I mean both of them are on seperate servers (machines) then you will just need to add LD_LIBRARY_PATH variable in your current user .bash_profile, i.e. the user who is installing all this here.

Now if you are installing through oracle user :

$ vi $HOME/.bash_profile

and add/edit following lines,

export ORACLE_HOME=/path/to/your/installdir
export ORACLE_BASE=/base/dir
export ORACLE_OWNER=user
export ORACLE_SID=database
export ORACLE_TERM=xterm
export TNS_ADMIN=/path/to/your/installdir/network/admin
export LD_LIBRARY_PATH=$HOME/instantclient_10_2/

But if you are not installing from oracle user, the case above discussed then:

$ vi $HOME/.bash_profile

and just this line:

export LD_LIBRARY_PATH=$HOME/instantclient_10_2/

Now are done with environment setup.

3. Installing Apache:

Now you have download Apache source to compile on your machine, here is the link to download:

http://httpd.apache.org/download.cgi

I am using Apache1.3. Now it depends on you, which apache version you wish to download, but still people recommend Apache1.3, and I will stick to this recommendation.

To open the Apache tar, change filename according to your apache release:

$ tar zxvf apache1.3....tar.gz
$ cd apache1.3...
$ ./configure --prefix=$HOME/apache --enable-so --with-mpm=prefork --with-port=8888

You can change port according to your need, even 80, but never try this on production server.

$ make
$ make install

Now we are done with Apache for now.

4. Installing PHP:

You can download your selected version of php source from,

http://www.php.net/downloads.php

My recommedation is PHP4.3.X I am using PHP 4.3.4 for my server. Now to open tar, do this:

$ tar zxvf php4.3.4..tar.gz
$ cd php4.3.4
$ ./configure --prefix=$HOME/php --with-apxs=$HOME/apache/bin/apxs --with-mysql=/usr --with-config-file-path=$HOME/apache/conf --with-oci8-instant-client=$HOME/instantclient_10_2 --enable-sigchild
$ make
$ make install
$ cp php.ini-recommended $HOME/apache/conf/php.ini

Add these lines to the $HOME/apache/conf/httpd.conf file:

      AddType application/x-httpd-php         .php
      AddType application/x-httpd-php-source  .phps

Restart Apache:

$ $HOME/apache/bin/apachectl start

To check the extension is configured, create a simple PHP script phpinfo.php where the web server can read it.

<?php
  phpinfo();
?>

Load the script into a browser using an "http://" URL. The browser page should contain an "oci8" section saying "OCI8 Support enabled".

Share this page:

2 Comment(s)