1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Enable PHP Support on Oracle HTTP Server

Discussion in 'Oracle' started by pradeep, Mar 26, 2007.

  1. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    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>
     
     
    Nascomguru likes this.
  2. lead.smart34

    lead.smart34 New Member

    Joined:
    Feb 14, 2008
    Messages:
    77
    Likes Received:
    0
    Trophy Points:
    0
    good info
     
  3. trinitybrown

    trinitybrown New Member

    Joined:
    Oct 23, 2008
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    UK
    Good article but why one should go for oracle when MySQL is there
     
  4. Jenniferlinn

    Jenniferlinn New Member

    Joined:
    Dec 24, 2008
    Messages:
    23
    Likes Received:
    3
    Trophy Points:
    0
    Occupation:
    search engine optimization
    Location:
    UK
    Home Page:
    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
     

Share This Page