Last updated 5 Mar 2005

Apache2+PHP5+Oracle Extension

Download

  1. Download Apache and PHP5
    Apache 2 apache_2.0.53-win32-x86-no_ssl.msi
    PHP5 (to install Oracle extension) php-5.0.4-Win32.zip

Install Apache2

  1. Execute apache_2.0.53-win32-x86-no_ssl.msi and follow the instructions.

Install PHP5

  1. Unzip php-5.0.4-Win32.zip and copy to C:\php with directory. You also can download php-5.0.4-installer.exe which will copy to C:\php directory automatically. However this does not include all modules as Oracle module. If you need to extend functions, you better download the zip version.
  2. To run PHP with Apache, open C:\Program Files\Apache Group\Apache2\conf\httpd.conf and add following lines at the end of the file
    Run as an Apache module
    #### Run as an Apache module
    LoadModule php5_module "c:/php/php5apache2.dll"
    AddType application/x-httpd-php .php
    PHPIniDir "C:/php"
    
    Run as a CGI
    #### Run as a CGI
    ScriptAlias /php/ "c:/php/"
    AddType application/x-httpd-php .php
    Action application/x-httpd-php "/php/php-cgi.exe"
    PHPIniDir "C:/php"
    
  3. Edit DirectoryIndex line at httpd.conf
    DirectoryIndex index.html index.html.var index.php
    
  4. Copy C:\php\php.ini-recommended to C:\php\php.ini
  5. Restart Apache

Test Apache

  1. To test Apache, open http://localhost. If you see Apache page saying "Seeing this instead of the website you expected?", your Apache is working.
  2. To test PHP, create C:\Program Files\Apache Group\Apache2\htdocs\phpinfo.php, and open http://localhost/phpinfo.php
    <? phpinfo(); ?>
    

Enable Oracle module

  1. Edit C:\php\php.ini and uncomment php_oci8.dll.
    ; extension_dir = "./"
    extension_dir = "C:\php\ext"
    
    ;extension=php_oci8.dll
    extension=php_oci8.dll
    
    Note: Oracle must be installed before enabling this
  2. Open phpinfo.php again and see whether oci8 module is installed or not.
  3. To test Oracle module, create C:\Program Files\Apache Group\Apache2\htdocs\oracle.php. Change the username and the password accordingly.
    <?php
      $dbh = OCILogon( "scott", "tiger", "localhost:1521/orcl" );
      if ($dbh == NULL) {
        print "DB Connection Error!!";
      } else {
        $sql = "SELECT table_name FROM all_tables";
        $stmt = OCIParse($dbh, $sql);
        if (!$stmt) {
          print "DB Search Error!!";
        } else {
          OCIExecute($stmt);
          $rows = OCIFetchstatement($stmt, $results);
          if ($rows > 0) {
            for ($i = 0; $i < $rows; $i++) {
              print $results["TABLE_NAME"][$i] . "<br>";
            }
          }   
        }
        OCIFreeStatement($stmt);
        OCILogoff($dbh);
      }
    ?>
    

Multibite String

  1. mbstring module can show multibite strings. The example is for Japanese language. Edit php.ini
  • For Shift JIS
  • ; mbstring configuration
    mbstring.language = Japanese
    mbstring.internal_encoding = EUC-JP
    mbstring.http_input = auto
    mbstring.http_output = SJIS
    mbstring.encoding_translation = On
    mbstring.detect_order = auto
    mbstring.substitute_character = none
    
    ; other configuration
    default_charset = "Shift_JIS"
    output_buffering = On
    output_handler=mb_output_handler
    
  • For EUC-JP
  • mbstring.language = Japanese
    mbstring.internal_encoding = EUC-JP
    mbstring.http_input = auto
    mbstring.http_output = EUC-JP
    mbstring.encoding_translation = On
    mbstring.detect_order = auto
    mbstring.substitute_character = none
    
    ; other configuration
    default_charset = "EUC-JP"
    

    Back - Support
    Google
    Web www.grape-info.com