PHP via Zen

<- Legacy


PHP is a very powerful language that can be used to write both web applications and Oracle maintenance scripts. In this way your environment can be easier to support as you would only have one scripting language. The following covers the essential steps to install and configure PHP for writing maintenance scripts for Oracle. The following example installs Zend Server on a Windows system.

Essential Support Info


  • Admin URL: http://localhost:10081/ZendServer
  • The httpd.conf is located in the directory: C:\Program Files\Zend\Apache2\conf
  • The php.ini is located in the directory: C:\Program Files\Zend\ZendServer\etc
  • The ServerRoot (default web documents directory) is: C:\Program Files\Zend\Apaches2\htdocs


  • The error.log (default Apache error log) is: C:\Program Files...\Zend\Apache2\logs\error.log
  • The php_error.log (default PHP error log) is: C:\Program Files...\Zend\ZendServer\logs\php_error.log
  • Messages are sometimes sent to the Windows Application event log.


  • Download Zend Server CE (Community Edition) matching your host OS.
    Example file name: ZendServer-CE-php-5.3.14-5.6.0-SP4-Windows_x86.exe
  • Oracle database or at least the Oracle client software (standard or instant) has been installed.
  • The Oracle environment variables are set: ORACLE_HOME etc.
  • No other web servers are installed\active on the host system.
  • Install a supported web browser. Check for supported browsers.
    This is used for configuration even if your goal is only to use PHP for maintenance scripts.
  • Create a directory for your command line scripts. Example: C:\app\scripts\php


RHEL\CentOS7 for PHP Dev Station

(x) Development & Creative Workstation   
[x] Addiional Dev
[x] Dev Tools
[x] PHP Support
[x] Tech Writing 

For Existing Linux System

  1. yum install httpd
    • systemctl start httpd.service
    • systemctl enable httpd.service
    • Test http://localhost
  2. yum install php
    • systemctl restart httpd.service
    • systemctl enable php.service
  3. Create Test File

Windows Installation

  1. Run downloaded setup file (ZendServer-CE-php-5.3.14-5.6.0-SP4-Windows_x86.exe).
  2. Welcome to the Zend Server Community Edition 5.x Installer.
  3. License Agreement
    (x) I accept ...
  4. Setup Type
    (*) Typical
  5. Web Server
    (x) Install an Apache 2.x Web Server
    Destination Folder: C:\Programs Files\Zend
  6. Installation Settings
    Select [Install] button.
    Installation process runs...
  7. Zend Server was successfully installed
    [x] Start working with Zend Server Community Edition
    Select [Finish] button.
  8. Browser launches initial setup (3 steps).
    1. Accept license agreement.
    2. Enter Password: ********
    3. Select [Finish] button.

Configuration and Testing

Configuration Changes

  • Set timeouts to allow ample script execution time.
      Examples (make higher if necessary):
      Apache - http.conf: TimeOut 600
      PHP - php.ini:      max_execution_time 300  
  • Set the date.timezone entry in the php.ini to avoid having to put a timezone entry in all your scripts.
    Example entry (place at bottom of the php.ini): date.timezone = America/New_York
    Otherwise use date_default_timezone_set. Example: date_default_timezone_set('America/New_York');
  • Set email SMTP server values in the php.ini.
    Usage: mail('', 'My Subject', 'Message here.');
      [mail function]
      SMTP =
      smtp_port = 25
      sendmail_from =

Command Line Script Test

  1. Create script as C:\app\scripts\php\pi.php
    <?php phpinfo(); ?>
  2. Run script from console window.
    OS> php pi.php
    Output of PHP values will be displayed if all is working OK.
  1. To get unbuffered, i.e. real-time output to the console use STDOUT not echo or print.
    Example: fwrite(STDOUT,"Hello World! \n");
  2. Make sure to run phpinfo() to determine which php.ini file your scripts are really using. It may not be what you think!

Oracle Database Connection Test

Create and run the following file as: C:\app\scripts\php\oracle_test.php

  // Connect to Oracle Database
  $connection = oci_connect("MyOracleUsername", "MyPassword",

  // Create Cursor
  $cursor = oci_parse($connection, "SELECT sysdate FROM dual");
  oci_execute ($cursor);

  // Output
  while ($row = oci_fetch_array ($cursor)) {
     // Two ways to output the same value of a field.
     // echo $row[0] . " ";
     echo $row['SYSDATE'] . " ";

  // Close Connection

SYSDBA Connection

  1. Enable this in your php.ini
    oci8.privileged_connect = 1
  2. Connect using OCI_SYSDBA Flag
    $connection = oci_connect("MyOracleUsername", "MyPassword", "",null,OCI_SYSDBA );

Run PHP Console Script Within Notepad++

-- Create Run Item
Press F6 then paste the below.

 php.exe $(NAME_PART).php
 Save as: PHP Run

-- Create NppExec Item
Go to Advance Options within NppExec plugin,

 A. Check the box at the top that says "Place to the Macros Submenu"
 B. Select script from "Associated Script" combo box. 
    It will automatically fill in the "Item Name".
 C. Now click the "Add/Modify" button.
 D. Click OK. This will exit the Advanced Options box and say that 
    NotePad++ needs to be restarted.

-- Assign to HotKey

 A. Navigate to: Settings -> Shortcut Mapper -> Plugin Commands -> PHP Run
 B. Right-Click -> Modify
 C. Select Ctrl-F1 (or other combo you desire)

Configure Zend CE for SSL

* Obtain the required files. Example: server.crt, gd_bundle.crt and server.key
  Change the file names to match your files (server.crt, server.key etc.).
* If you need to create a keystore file (.key) you must install openssl.exe.
  Windows Binaries:

File Operations
1. Copy all Cert and Key Files to C:\...\Apache2
2. Make copies of the files:

1. Edit the file C:\Program Files...\Zend\Apache2\conf\httpd.conf
   Uncomment: LoadModule ssl_module modules/
   Uncomment: Include "conf/extra/httpd-ssl.conf"

2. Edit the file C:\Program Files...\Zend\Apache2\conf\extra\httpd-ssl.conf

   a. "SSL Cipher Suite" section values should be uncommented (and similar to these):
      SSLProtocol all
      SSLCipherSuite HIGH:MEDIUM
      SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5

   b. Set "Server Certificate" section "SSLCertificateFile" value:
      SSLCertificateFile "server.crt"

   c. Set "Server Private Key" section "SSLCertificateKeyFile" value:
      SSLCertificateKeyFile "server.key"

   d. Set "Server Certificate Chain" section "#SSLCertificateChainFile" value:
      SSLCertificateChainFile "gd_bundle.crt"

   e. Change SSLSessionCache Path.  
      This is actually a bug work around for Windows version on 64-bit systems.
      SSLSessionCache "shmcb:C:/PROGRA\~2/Zend/Apache2/logs/ssl_scache(512000)"

3. Bounce the Apache Windows Service

4. Tests
   a. https://localhost
   b. https://phpinfo.php

<- Legacy