When you install an Oracle database, you automatically install an Apache 1.3 HTTP server on which the database relies for many of its products and features. It seems to be a waste of resources to install a second Web server for database-driven Web site development on a single machine. It would be more efficient to simply add modules to the Oracle Apache server to support additional products. This column describes the necessary steps for installing PHP support on the Oracle 9i default Apache Web server. We'll use Windows paths and names, but UNIX and other operating systems should be similar. (Note that Oracle has announced that Oracle 10g will include PHP support.) The first step is to obtain the PHP module for your desired Web site from php.net. Download this module, unzip it into a directory, and build binaries (if needed) according to the installation scripts. From this point forward, I'll use c:\php as the installation root for the PHP directory containing the executables, and I'll use c:\oracle\ora92 as my Oracle Home. Second, copy the file php4ts.dll (the scripting engine) into the sapi subdirectory. This is needed by php4apache.dll, and it's easier to locate if it's in the same directory. Third, create a php.conf file to contain your PHP-specific settings for Oracle's Apache server: Code: # Apache configuration to enable PHP LoadModule php4_module c:/php/sapi/php4apache.dll AddModule mod_php4.c AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps Save this file in the $ORACLE_HOME/Apache/Apache/conf directory. Reference it from the httpd.conf file with this line (at the very end--after oracle.conf's include): Code: include "C:/oracle/ora92/Apache/Apache/conf/php.conf" Finally, copy the file php.ini-recommendation to the C:/oracle/ora92/Apache/Apache directory as php.ini. You need to enable the oracle extension to be able to access the database. First, make sure the extension_dir has the full path instead of the default "./" directory: Code: extension_dir = "c:/php/extensions/" Then, uncomment the line referencing the Oracle module: Code: extension=php_oracle.dll Restart the Web server normally and check for errors. You should be able to write a very simple PHP script (save as test.php in $ORACLE_HOME/Apache/Apache/htdocs): HTML: <html> <Title>PHP Test</Title> <body> <?php echo "Hello World"; ?> </body> </html> You should also be able to run a full PHP script, which accesses an Oracle database via PHP extension calls (save it as oratest.php in $ORACLE_HOME/Apache/Apache/htdocs). PHP: <html> PHP Test with Oracle<head> <body> <pre> <?php $conn = ora_logon("scott","tiger"); ora_commitoff($conn); $cursor = ora_open($conn); ora_parse($cursor,"select initcap(ename) from emp order by 1"); ora_exec($cursor); while (ora_fetch($cursor)) { $ename = trim(ora_getcolumn($cursor,"ENAME")); echo $ename."\n"; } ?> </pre> </body> </html>
Hello pardeep Thanks for the post as till now i never think to use any other database with PHP but now i will try to use oracle with PHP