Integrate Oracle 10g, Apache 2.0, PHP 5

xiaoxiao2021-03-06  50

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

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:

>

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):

$ db_conn = Ocilogon ("Scott", "Tiger", "TEST");

$ cmdstr = "SELECT ENAME, SAL FROM EMP";

$ pased = ociparse ($ db_conn, $ cmdstr);

Ociexecute ($ parse);

$ nROWS = OcifetchStatement ($ PARSED, $ RESULTS);

Echo " Oracle PHP Test </ title> </ head> <body>";</p> <p>Echo "<center> <H2> Oracle PHP TEST </ H2> <br>";</p> <p>Echo "<Table Border = 1 Cellspacing = '0' width = '50% '> / N / <Tr> / N";</p> <p>ECHO "<TD> <B> Name </ b> </ td> / n <td> <b> Salary </ B> </ td> / n </ tr> / n";</p> <p>For ($ I = 0; $ i <$ nrows; $ i )</p> <p>{</p> <p>ECHO "<tr> / n";</p> <p>Echo "<TD>". $ Results ["ENAME"] [$ I]. "</ td>";</p> <p>Echo "<TD> $". Number_Format ($ RESULTS ["SAL"] [$ I], 2). "</ td>";</p> <p>ECHO "</ TR> / N";</p> <p>}</p> <p>Echo "<tr> <td colspan = '2'> Number of Rows: $ nROWS </ TD> </ TR> </ table>";</p> <p>Echo "<br> <em> if you see data, theen it works! </ em> <br> </ center> </ body> </ html> / n";</p> <p>?></p> <p>Explanation: In the above example, Scott / Tiger is the username and password of the database, and TEST is the database connection string name. Reference documentation</p> <p>Installing Oracle, PHP, And Apache on Linux by Robert Clevenger PHP: Apache 2.0 on unix systems - http://www.php.net/manual/en/install.unix.Apache2.php</p> <p>More information</p> <p>Oracle Open Source Developer Center - http://www.racle.com/technology/tech/opensource/index.html</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-87891.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="87891" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.054</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'Sw4kjxW_2F21_2B2Yq6aDjGwINyEDAJHBM7UmZIg9dsjXKvXens8M7pvrSf_2BIg_2F2euwP8wL7TRb1D7lRkEPhKRlWrg_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>