September 2010
M T W T F S S
« Apr    
 12345
6789101112
13141516171819
20212223242526
27282930  

Traditional Way for Installing PHP(OCI enabled) + Apache on Linux

Actually, the traditional way is compiling source from scratch. Below is information from OTN:
Installing Apache, PHP, JDeveloper, and the PHP Extension on Linux

Apache 1.3

  1. Login as Oracle user.
  2. Copy/download apache_1.3.31.tar.gz
  3. tar -zxf apache_1.3.31.tar.gz
  4. cd apache_1.3.31
  5. Configure:
    ./configure --enable-module=so --prefix=$HOME/apache --with-port=8888
  6. Build: make
  7. Install: make install
  8. Start Apache: $HOME/apache/bin/apachectl start
  9. Go to a browser and check that http://localhost:8888/ returns the default "Powered by Apache" page.
  10. Stop Apache: $HOME/apache/bin/apachectl stop

PHP 4.3

Before you proceed, make sure that the packages "bison" and "flex" are installed, because PHP needs them.

  1. Copy/download php-4.3.9.tar.gz
  2. tar -zxf php-4.3.9.tar.gz
  3. Set environment variable ORACLE_SID
  4. Set environment variable ORACLE_HOME
  5. Set environment variable LD_LIBRARY_PATH to $ORACLE_HOME/lib:${LD_LIBRARY_PATH}
  6. Configure (make sure to enter this as one long line):
    ./configure --prefix=$HOME/php --with-apxs=$HOME/apache/bin/apxs
     --with-config-file-path=$HOME/apache/conf
     --with-oci8=$ORACLE_HOME --enable-sigchild
  7. Build: make
  8. Install: Make install
  9. cp php.ini-recommended $HOME/apache/conf/php.ini
  10. Edit $HOME/apache/conf/httpd.conf and add:
    AddType application/x-httpd-php        .php
    AddType application/x-httpd-php-source .phps

  11. Restart Apache
  12. create $HOME/apache/htdocs/phpinfo.php as:
       1: <?php
       2:   phpinfo();
       3: ?>

  13. In a browser load http://localhost:8888/phpinfo.php. Check that the OCI module is listed.

Following exactly the steps above, you will get PHP + Apache running on Linux.

NOTES:–with-apxs in step 6 when installing PHP is important, this let the installation process to compile the OCI library for the apache and make it available to Apache.

For testing the OCI support in PHP, create $HOME/apache/htdocs/connect.php as:

   1: <?php 
   2:  
   3: define('ORA_CON_UN', 'scott');
   4: define('ORA_CON_PW', 'tiger');
   5: define('ORA_CON_DB', 'MYSID');
   6:  
   7: $conn = OCILogon(ORA_CON_UN, ORA_CON_PW , ORA_CON_DB );
   8:  
   9: if (!$conn) {
  10: exit;
  11:   }
  12:  
  13: echo OCIServerVersion($conn) ."<br>\n";
  14: echo "Connected as ".ORA_CON_UN."</br>\n";
  15: echo date('Y-m-d H:i:s')."<br><br>\n";
  16:  
  17: $query = 'select * from emp';
  18:  
  19: $stid = OCIParse($conn, $query);
  20: OCIExecute($stid, OCI_DEFAULT);
  21: print "<table border='1'>\n";
  22: while ($succ = OCIFetchInto($stid, $row, OCI_RETURN_NULLS)) {
  23: print "<tr>\n";
  24: foreach ($row as $item) {
  25: print '<td>';
  26: print isset($item)?htmlentities($item):'?';
  27: print "</td>\n";
  28:     }
  29: print "</tr>\n";
  30:   }
  31: print "</table>\n";
  32:  
  33: OCILogoff($conn);
  34: ?>

In a browser load http://localhost:8888/connect.php. Check that the OCI driver works.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>