note 27519 added to ref.oci8
| From: | php-general at lists dot php dot net | Date: | Mon, 09 Dec 2002 19:53:35 +0000 |
| Subject: | note 27519 added to ref.oci8 | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-40624@lists.php.net to get a copy of this message | ||
Configuring/Compiling PHP as a DSO with Oracle support from source on a Sun Solaris 8 box. We had
already installed Oracle 9.2.0 client tools.
1. Make sure the following tools are installed
autoconf
automake
bison
flex
gcc
make
gzip
They can be downloaded from http://www.sunfreeware.com.
2. Make sure Apache is installed with DSO support. We ran the Apache configure/compile like so:
LIBS=-lpthread ./configure \
--prefix=/usr/local/apache \
--enable-module=most \
--enable-shared=max
make
make install
3. If you haven't already, install the Oracle client tools.
4. Make sure the following environment variables are set correctly and are accessible by all users.
We set them in /etc/profile.
ORACLE_HOME
ORACLE_BASE
NLS_LANG
ORA_NLS33
ORACLE_TERM
LD_LIBRARY_PATH
(technically, only $ORACLE_HOME is required, but you'll want to set the rest in order to make
sure things run smoothly afterward)
5. Make sure '/usr/ccs/bin' is in your path. If not, add it.
6. Unpack PHP source (php-4.2.3):
gunzip php-4.2.3.tar.gz
tar xvf php-4.2.3.tar
cd php-4.2.3
7. Run PHP configure like so :
CC=gcc ./configure --with-apxs=/usr/local/apache/bin/apxs \
--with-config-file-path=/etc \
--with-mysql \
--enable-ftp \
--with-oci8=/path/to/ORACLE_HOME \
--with-oracle=/path/to/ORACLE_HOME \
--enable-sigchild
8. Run make: make
9. Run this as root: make install
10. Change the LoadModule line in httpd.conf to include the fully qualified path. For us:
LoadModule php4_module /usr/local/apache/libexec/libphp4.so
11. Make sure the PHP files types are recognized in your httpd.conf file:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
12. Test the configuration:
/usr/local/apache/bin/apachectl configtest
It should return "Syntax OK"
13. Bounce Apache:
/usr/local/apache/bin/apachectl restart
14. Here's a simple PHP script to test the setup. If you don't have access to the
default tables Oracle provides, change the connections/tablenames/fields to match your setup:
<?php
$db_conn = ocilogon("scott", "tiger");
$cmdstr = "select ename, sal from emp";
$parsed = ociparse($db_conn, $cmdstr);
ociexecute($parsed);
$nrows = ocifetchstatement($parsed, $results);
echo "Found: $nrows results<br><br>\n";
echo "<table border=1 cellspacing='0' width='50%'>\n";
echo "<tr>\n";
echo "<td><b>Name</b></td>\n";
echo "<td><b>Salary</b></td>\n";
echo "</tr>\n";
for ($i = 0; $i < $nrows; $i++ ) {
echo "<tr>\n";
echo "<td>" . $results["ENAME"][$i] . "</td>";
echo "<td>$ " . number_format($results["SAL"][$i], 2).
"</td>";
echo "</tr>\n";
}
echo "</table>\n";
?>
--
http://www.php.net/manual/en/ref.oci8.php
http://master.php.net/manage/user-notes.php?action=edit+27519
http://master.php.net/manage/user-notes.php?action=delete+27519
http://master.php.net/manage/user-notes.php?action=reject+27519