Change your directory to "apache-1.3" and configure Apache.
ATTENTION : --server-uid parameter value corresponds to the name of Oracle User (' oracle ' in this tutorial) and --server-gid parameter corresponds to the primary group of Oracle User (' dba ' in this turorial). You have change these values according to your Oracle username and group.
( Change this configuration parameters according to your needs. Refer INSTALL file in APACHE Source folder or type ./configure --help )
# cd apache-1.3
# LIBS=-lpthread CC=gcc \
./configure --prefix=/usr/local/apache \
--server-uid=oracle \
--server-gid=dba \
--enable-shared=max \
--enable-module=most
#make
#make install
If you have an error at this stage you have to solve the problem and try again.
Then change your directory to "php-4.3.2" and configure PHP.
(
Change this configuration parameters according to your
needs. Refer INSTALL file in PHP Source folder or type
./configure --help
)
# cd php-4.3.2
# CC=gcc CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib \
./configure --with-apxs=/usr/local/apache/bin/apxs \
--with-config-file-path=/usr/local/apache/conf \
--with-oci8=/opt/oracle/product/8.1.7 \
--with-oracle=/opt/oracle/product/8.1.7 \
--disable-libgcc
#make
#make install
If you have an error at this stage you have to solve the problem and try again.
If you have make all right, you copy "php.ini-dist" to
"/usr/local/apache/conf/" directory named as "php.ini".
#cp php.ini-dist /usr/local/apache/conf/php.ini
Edit this file according to your needs by using any text editor. Especially look for
output_buffering=Off
line and change it as follows:
output_buffering=4096
You also have to edit "httpd.conf" file of Apache Web Server. Open "httpd.conf" file by using any text editor and add the following lines to the very end of the file:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
Additionaly change
#ServerName xxxxxx
line. xxxxxx refers to your computer name. Remove '
#
' sign and add your
hostname with xxxxxx. As an example, this line will look like similarly:
ServerName gokmen.selcuk.edu.tr
Create a file named "info.php" in your "DocumentRoot" directory and add this line in it:
#touch /usr/local/apache/htdocs/info.php
#echo "" >> /usr/local/apache/htdocs/info.php
If you made all right, you are ready to start apache by typing:
#/usr/local/apache/bin/apachectl start
Now, open your web browser and type following in address bar:
http:///info.php
and look for " oci8 " and " oracle " section in this php information page loaded. If you see these section you completed everything succssfully.
I assume that you have already a PHP file for use to connect Oracle. Create
or Copy any one of them
into "DocumentRoot" ("/usr/local/apache/htdocs" in here) and try to run it
in your browser.
I hope you did not get an error like
Warning: ocilogon(): _oci_open_server: Error while trying to retrieve text for
error ORA-12545 in ....
This error is telling you did not specify "ORACLE_SID" in your script or
Warning: ocilogon(): _oci_open_server: Error while trying to retrieve text for
error ORA-12154 in ...
This error could not find any match "ORACLE_SID" you specified in "TNSNAMES.ORA" file.
If you got one of these error, your environment variables must introduce to your apache web server.
Remember that you compiled apache with Oracle user and group. So, do the following:
create a file named "oraenv" in "/usr/local/apache/conf/" directory and put
the following lines in it:
(
IMPORTANT : Please change
Here is an example for this "oraenv" file:
LD_LIBRARY_PATH=/opt/oracle/product/8.1.7/lib:/usr/local/apache/lib:
/usr/local/lib
ORACLE_HOME=/opt/oracle/product/8.1.7
ORACLE_SID=/opt/oracle/product/8.1.7
TNS_ADMIN=/opt/oracle/product/8.1.7http://felipecruz.com/admin
NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1 #for English
#NLS_LANG=TURKISH_TURKEY.WE8ISO8859P9 #for Turkish
ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
If you want You may insert these lines into "/usr/local/apache/bin/apachectl"
file directly.
Now You need to edit "/usr/local/apache/bin/apachectl" file.
Open it by a text editor and add the following lines to anywhere in the
"CONFIGURATION SECTION"
if [ -f /usr/local/apache/conf/oraenv ] ;
then
. /usr/local/apache/conf/oraenv
fi
Also something usefull to have around , this is an official generated oraenv file:
class oraClass
{
var $sql, $stmt, $conn, $nrows, $ncols, $errmsg, $user, $pass;
function db_connect()
{
if($this->conn = OCILogon($this->user, $this->pass,
$_ENV['ORACLE_SID']))
$this->db_parse();
else
$this->get_error($this->conn);
}
.
.
.
:
#
# $Header: oraenv.sh.pp 23-may-2002.08:05:24 jboyce Exp $ oraenv.sh.pp Copyr (c) 1991 Oracle
#
###################################
#
# usage: . oraenv
#
# This routine is used to condition a user's environment for access to
# an ORACLE database. It will prompt for the value of the new SID unless
# the variable ORAENV_ASK is set to NO, in which case it will use the
# current value of ORACLE_SID.
# The character "*" denotes a null SID.
#
# NOTE: Due to constraints of the shell in regard to environment
# ----- variables, the command MUST be prefaced with ".". If it
# is not, then no permanent change in the user's environment
# can take place.
#
#####################################
case ${ORACLE_TRACE:-""} in
T) set -x ;;
esac
#
# Determine how to suppress newline with echo command.
#
N=
C=
if echo "\c" | grep c >/dev/null 2>&1; then
N='-n'
else
C='\c'
fi
#
# Set minimum environment variables
#
# ensure that OLDHOME is non-null
if [ ${ORACLE_HOME:-0} = 0 ]; then
OLDHOME=$PATH
else
OLDHOME=$ORACLE_HOME
fi
case ${ORAENV_ASK:-""} in #ORAENV_ASK suppresses prompt when set
NO) NEWSID="$ORACLE_SID" ;;
*) case "$ORACLE_SID" in
"") ORASID=$LOGNAME ;;
*) ORASID=$ORACLE_SID ;;
esac
echo $N "ORACLE_SID = [$ORASID] ? $C"
read NEWSID
case "$NEWSID" in
"") ORACLE_SID="$ORASID" ;;
*) ORACLE_SID="$NEWSID" ;;
esac ;;
esac
export ORACLE_SID
ORAHOME=`dbhome "$ORACLE_SID"`
case $? in
0) ORACLE_HOME=$ORAHOME ;;
*) echo $N "ORACLE_HOME = [$ORAHOME] ? $C"
read NEWHOME
case "$NEWHOME" in
"") ORACLE_HOME=$ORAHOME ;;
*) ORACLE_HOME=$NEWHOME ;;
esac ;;
esac
export ORACLE_HOME
#
# Put new ORACLE_HOME in path and remove old one
#
case "$OLDHOME" in
"") OLDHOME=$PATH ;; #This makes it so that null OLDHOME can't match
esac #anything in next case statement
case "$PATH" in
*$OLDHOME/bin*) PATH=`echo $PATH | \
sed "s;$OLDHOME/bin;$ORACLE_HOME/bin;g"` ;;
*$ORACLE_HOME/bin*) ;;
*:) PATH=${PATH}$ORACLE_HOME/bin: ;;
"") PATH=$ORACLE_HOME/bin ;;
*) PATH=$PATH:$ORACLE_HOME/bin ;;
esac
export PATH
#
# Install any "custom" code here
#
# Locate "osh" and exec it if found
ULIMIT=`LANG=C ulimit 2>/dev/null`
if [ $? = 0 -a "$ULIMIT" != "unlimited" ] ; then
if [ "$ULIMIT" -lt 2113674 ] ; then
if [ -f $ORACLE_HOME/bin/osh ] ; then
exec $ORACLE_HOME/bin/osh
else
for D in `echo $PATH | tr : " "`
do
if [ -f $D/osh ] ; then
exec $D/osh
fi
done
fi
fi
fi