Installing Oracle 10g R2, Apache (2.0.54) and PHP (5.0.4) on CentOS 4.1 (RHEL 4 U1)
This article has been compiled from different pieces located in different places at OTN. My effort was only to bring
all stuff together, test it works and make easy to understand the core technology based on Instant-Client installation on the CentOS 4.1 Linux box already running Oracle10g R2 database server.Note,that if database TNSLISTENER port is different from 1521,port number should be specified in the connect string for sqlplus.
Instant Client allows you to run your applications without installing the standard Oracle client or having an ORACLE_HOME. OCI, OCCI, Pro*C, ODBC, and JDBC applications work without modification, while using significantly less disk space than before. Even SQL*Plus can be used with Instant Client. No recompile, no hassle.Customers can try new packaged applications and Oracle client features quickly without worrying about other installations. Larger enterprises can automate setup and configuration of Instant Client by using installation scripts accessing a central IT repository. Finally, everyone can benefit from the smaller footprint
Download from:-
http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html
Instant Client Package - Basic: All files required to run OCI, OCCI,
and JDBC-OCI Applications
oracle-instantclient-basic-10.2.0.1-1.i386.rpm
instantclient-basic-linux32-10.2.0.1-20050713.zip
Instant Client Package - SQL*Plus: Additional libraries and executable
for running SQL*Plus with Instant Client
oracle-instantclient-sqlplus-10.2.0.1-1.i386.rpm
instantclient-sqlplus-linux32-10.2.0.1-20050713.zip
Instant Client Package - SDK: Additional header files and an example makefile
for developing Oracle applications with Instant Client
oracle-instantclient-devel-10.2.0.1-1.i386.rpm
instantclient-sdk-linux32-10.2.0.1-20050713.zip
Install PHP, Apache and Oracle Instant Client
Installing and testing Instant Client
Run as root:-
# rpm -Uvh oracle-instantclient-basic-10.2.0.1-1.i386.rpm
# rpm -Uvh oracle-instantclient-sqlplus-10.2.0.1-1.i386.rpm
# rpm -Uvh oracle-instantclient-devel-10.2.0.1-1.i386.rpm
# useradd -g oinstall -G dba orauser
# passwd orauser
Login as orauser.Test connection to the database:
$ export LD_LIBRARY_PATH= /usr/lib/oracle/10.2.0.1/client/lib
$ /usr/lib/oracle/10.2.0.1/client/bin/sqlplus scott/drbrxa@//ServerORCL.informatics.dstu.net/rawdbase
SQL> exit
Installing and testing Apache
Login as your "orauser" user
Build Apache:
$ bzcat httpd-2.0.54.tar.bz2 tar xf -
$ cd httpd-2.0.54
$ ./configure --prefix=$HOME/apache --enable-so --with-mpm=prefork
$ make
$ make install
Edit $HOME/apache/conf/httpd.conf and change the port to 8888:
Listen hostname:8888
Start Apache:
$HOME/apache/bin/apachectl start
Start a browser and check that http://hostname:8888/ gives the
default Apache web page.
Stop Apache:
$HOME/apache/bin/apachectl stop
Installing and testing PHP
Build PHP:
$ bzcat php-5.0.4.tar.bz2 tar xf -
$ cd php-5.0.4
$ ./configure --prefix=$HOME/php --with-apxs2=$HOME/apache/bin/apxs --with-config-file-path=$HOME/apache/conf --with-oci8-instant-client= /usr/lib/oracle/10.2.0.1/client/lib --enable-sigchild
$ make
$ make install
$ cp php.ini-recommended $HOME/apache/conf/php.ini
Edit php.ini and change display_errors to On:
display_errors = On
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
LD_LIBRARY_PATH should contains /usr/lib/oracle/10.2.0.1/client/lib before
starting Apache
Test it all works
TEST 1:
Create a file $HOME/apache/htdocs/phpinfo.php containing:
<?php
phpinfo();
?>
Load this file in a browser:
http://hostname:8888/phpinfo.php
Check the value of LD_LIBRARY_PATH in the Environment section.
it should contain the Instant Client directory.
Check that there is a section "oci8" with OCI8 Support marked as
"enabled".
TEST 2:
Create a file $HOME/apache/htdocs/test.php containing:
<?php
$conn = OCILogon("scott", "tiger", "//hostname:tns_listener_portnumber/orclraw");
if (!$conn) {
exit;
}
echo OCIServerVersion($conn) ."<br>\n";
print date('Y-m-d H:i:s')."<br><br>\n";
$query = 'SELECT * FROM EMP';
$stid = OCIParse($conn, $query);
OCIExecute($stid, OCI_DEFAULT);
print '<table border="1">';
while ($succ = OCIFetchInto($stid, $row, OCI_RETURN_NULLS)) {
print '<tr>';
foreach ($row as $item) {
print '<td>'.($item?htmlentities($item):' ').'</td>';
}
print '</tr>';
}
print '</table>';
OCILogoff($conn);
?>
Load this file in a browser:
http://hostname:8888/test.php