OTN's Oracle & PHP installguide ---------------------------------------------------------------- Installing Oracle 10g (10.2), Apache (2.0.54), and PHP (5.0.4) on RHEL4 *** This guide is for test purposes only - not production *** Pre-install step: Install Oracle 10.2 (not discussed here) as the "oracle" user. Start Oracle and configure a test database-user account Start the Oracle Database Login as "oracle": su - oracle Set the software home directory locator ORACLE_HOME appropriately, eg.: export ORACLE_HOME=/home/oracle/oracle/product/10.2.0/db_1` Set the Oracle system identifier ORACLE_SID appropriately, eg.: export ORACLE_SID=orcl Set PATH to include $ORACLE_HOME/bin for example: export PATH=$ORACLE_HOME/bin:$PATH Startup the database: sqlplus / as sysdba SQL> startup SQL> exit Ignore error "ORA-01081: cannot start already-running ORACLE" if your database is already running. Start the Oracle Network listener: lsnrctl start Ignore error "TNS-01106: Listener using listener name LISTENER has already been started" if the listener was already running. Unlock the SCOTT schema: sqlplus / as sysdba SQL> alter user scott account unlock identified by tiger; SQL> exit Install PHP, Apache and Oracle Instant Client Installing and testing Instant Client Login as yourself (or any other "normal" user for testing) Install the Instant Client "basic" libraries, the SDK so PHP can be built, and the SQL*Plus package for connection testing: cd $HOME unzip instantclient-basic-linux32-10.2.0.1-20050713.zip unzip instantclient-sdk-linux32-10.2.0.1-20050713.zip unzip instantclient-sqlplus-linux32-10.2.0.1-20050713.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 Test connection to the database: export LD_LIBRARY_PATH=$HOME/instantclient_10_2/ $HOME/instantclient_10_2/sqlplus -l scott/tiger@//localhost/orcl SQL> exit Installing and testing Apache Login as your "normal" 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. Start Apache: $HOME/apache/bin/apachectl start Start a browser and check that http://localhost: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=$HOME/instantclient_10_2 \ --enable-sigchild make make install cp php.ini-recommended $HOME/apache/conf/php.ini Edit php.in 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 (Make sure LD_LIBRARY_PATH contains $HOME/instantclient_10_2 before starting Apache) Test it all works Test 1: Create a file $HOME/apache/htdocs/phpinfo.php containing: Load this file in a browser: http://localhost: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: \n"; print date('Y-m-d H:i:s')."

\n"; $query = 'SELECT * FROM EMP'; $stid = OCIParse($conn, $query); OCIExecute($stid, OCI_DEFAULT); print ''; while ($succ = OCIFetchInto($stid, $row, OCI_RETURN_NULLS)) { print ''; foreach ($row as $item) { print ''; } print ''; } print '
'.($item?htmlentities($item):' ').'
'; OCILogoff($conn); ?> Load this file in a browser: http://localhost:8888/test.php