Integration of Oracle 10g, Apache 2.0, Php 5 Author: Fenng
Date: 22-NOV-2004
Source:
http://www.dbanotes.net
Version: 0.01
basic introduction
On July 13, 2004, the official website officially released PHP 5. Oracle announced in August 2004 to provide support for PHP in your fist product Application Server. First, in Oracle Application Server 10g (9.0.4), the MOD_PHP module is provided, which is later provided in Oracle Application Server 10g Release 2 (10.1.2), which is also available in Oracle JDeveloper 10g, will also provide PHP extension capabilities. I believe that Soon Oracle will formally support PHP 5. With the vigorous promotion of the Oracle technology community, more developers will use PHP to develop large database references.
There is already a document describing how to make 10G / httpd 1.3 / php 4 integration. So this document will describe how to integrate Oracle 10g, Apache (HTTPD 2), PHP 5. Easy to quickly form a development environment. If you want to experience some new features of PHP (such as PDO), this article can be used as a start.
The relationship between the three of Oracle, Apache, and PHP may wish to borrow this schematic (original address):
This article assumes that your Oracle 10G (server or client) has been installed. If you don't have installed, please refer to this document:
http://www.dbanotes.net/oracle/install-oracle10g-rhel3.htm
Determine your own Oracle is available.
The operating system hosted herein is Fedora Core 3 Linux, and the Oracle version is 10 R1 (10.1.0.2).
Download the desired file: httpd and php 5
Httpd - httpd: //httpd.apache.org (current version is 2.0.52)
PHP 5 - http://www.php.net (the latest version is 5.0.2)
Install httpd
It should be noted that the Apache community is now not recommended to use Apache 2.0 in the product environment.
[root @ fc3 Software] # tar -zxvf httpd-2.0.52.tar.gz
[root @ fc3 Software] # CD httpd-2.0.52
[root @ fc3 httpd-2.0.52] # ./configure --prefix = / usr / local / apache /
--enable-module = so
[root @ fc3 httpd-2.0.52] # make clean
[root @ fc3 httpd-2.0.52] # Make
[root @ fc3 httpd-2.0.52] # make install
[root @ fc3 httpd-2.0.52] # / usr / local / apache / bin / apachectl start
[root @ fc3 httpd-2.0.52] # / usr / local / apache / bin / apachectl stop
Installation Description: The third line Specifies the architectural file installation location of the Apache architecture. At the same time, specify the form of the module will be used.
If you are for convenience, you can create two script control Apache boots and off.
[root @ fc3 ~] # vi / bin / startapache
Add the following:
#! / bin / sh
Oracle_Home = / U01 / App / Oracle / Product / 10.1.0 / db_1racle_sid = TEST
Export Oracle_Home Oracle_sid
Echo Starting Apache
/ usr / local / apache / bin / apachectl start
Create a script that closes Apache:
[root @ fc3 ~] # vi / bin / stopapache
Add the following:
#! / bin / sh
Oracle_Home = / U01 / App / Oracle / Product / 10.1.0 / db_1
Oracle_sid = TEST
Export Oracle_Home Oracle_sid
Echo Starting Apache
/ usr / local / apache / bin / apachectl stop
Modify file permissions:
[root @ fc3 ~] chmod x / bin / startapache / bin / stopapache
Install PHP 5
[root @ fc3 Software] # tar -xjf php-5.0.2.tar.bz2
[root @ fc3 software] # CD PHP-5.0.2
[root @ fc3 php-5.0.2] # e et or_base = / u01 / app / oracle
[root @ fc3 php-5.0.2] # @ @ e or h = $ oracle_base / product / 10.1.0 / db_1
[root @ fc3 php-5.0.2] # @ @ e e ac_sid = TEST
[root @ FC3 PHP-5.0.2] # ion path = $ PATH: $ HOME / BIN: $ Oracle_Home / Bin
[root @ fc3 php-5.0.2] # @ @ @ @ e l l l = = = =
[root @ fc3 php-5.0.2] # ./configure --with-apxs2 = / usr / local / apache / bin / apxs /
--with-oci8 = $ oracle_home
[root @ fc3 php-5.0.2] # make clean
[root @ FC3 PHP-5.0.2] # MAKE
[root @ fc3 php-5.0.2] # make install
[root @ FC3 PHP-5.0.2] # cp php.ini-dist /usr/local/lib/php.ini
Installation Description: The third to seven lines are actually a bit Luo Tao, the purpose is to control the environment variables of the root user, in fact, can also develop environment variables directly in the ROOT user .bash_profile file. Of course, it is also possible to use Oracle users to make configure and make. The eight lines --with-oci8 = $ oracle_home activates OCI8 support.
Next, you need to modify the contents of the httpd.conf file:
[root @ FC3 PHP-5.0.2] # vi /usr/local/apache/conf/httpd.conf
Add the following:
LoadModule PHP5_MODULE MODULES / LIBPHP5.SO
AddType Application / X-httpd-php .php
Ifmodule>
Restart Apache:
[root @ fc3] # / bin / stopapache
[root @ fc3] # / bin / startapache test PHP module
Test if the PHP module is already available. Of course, it is a standard approach to write a PHP page containing the following info.php:
php phpinfo ();?>>
View this page output content from your browser.
Note that the content in this page configure command is included in the following content:
'--With-apxs2 = / usr / local / apache / bin / apxs'
'--with-oci8 = / u01 / app / oracle / product / 10.1.0 / db_1'
Note: After the test, please delete the file for security considerations.
Test PHP OCI
Write a simple page test OCI is available (Just A Copy Sample From OTN):
PHP
$ db_conn = Ocilogon ("Scott", "Tiger", "TEST");
$ cmdstr = "SELECT ENAME, SAL FROM EMP";
$ pased = ociparse ($ db_conn, $ cmdstr);
Ociexecute ($ parse);
$ nROWS = OcifetchStatement ($ PARSED, $ RESULTS);
Echo "
Echo "
Echo "