整合Oracle 10g、Apache 2.0、Php 5
欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入 基本介绍 2004 年 7 月 13 日 , PHP 官方站点正式发布了 PHP 5 。 Oracle 在 2004 年 8 月宣布将在拳头产品 Application Server 中提供对 PHP 的支持。先是在 Oracle Application Server 10g ( 9.0
欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入
基本介绍
在 OTN 上已经有文档描述如何进行
Oracle、Apache、PHP三者之间的关系不妨借用一下这张示意图(原图地址):
本文假定您的 Oracle
http://www.dbanotes.nethttp://oracle.chinaitlab.com/Install-Oracle10g-RHEL3.htm
确定自己的 Oracle 处于可用状态。
本文所拥的操作系统为 Fedora Core 3 Linux,Oracle 版本为10 R1 (
下载所需文件:HTTPD 和 PHP 5
HTTPD - httpd://httpd.apache.org (目前的版本是
PHP 5 - http://www.php.net (最新版本是
安装HTTPD
需要说明的是,现在 Apache 社区不推荐把 Apache 2.0 用在产品环境中.
[root@FC3 software]# tar -zxvf httpd-
[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
[root@FC3 httpd-2.0.52]# /usr/local/apache/bin/apachectl stop
安装说明:第三行指定 Apache 的架构独立的文件安装位置。同时指定将用模块的形式。
如果为了方便的话,可以创建两个脚本控制 Apache 的启动与关闭。
[root@FC3 ~]# vi /bin/
添加如下内容:
#!/bin/sh
ORACLE_HOME=/u01/app/oracle/product/
ORACLE_SID=TEST
export ORACLE_HOME ORACLE_SID
echo
/usr/local/apache/bin/apachectl
创建关闭 apache 的脚本:
[root@FC3 ~]# vi /bin/stopapache
添加如下内容:
#!/bin/sh
ORACLE_HOME=/u01/app/oracle/product/
ORACLE_SID=TEST
export ORACLE_HOME ORACLE_SID
echo
/usr/local/apache/bin/apachectl stop
修改文件权限:
[root@FC3 ~] chmod +x /bin/
安装 PHP 5
[root@FC3 software]# tar -xjf php-
[root@FC3 software]# cd php-5.0.2
[root@FC3 php-5.0.2]# export ORACLE_BASE=/u01/app/oracle
[root@FC3 php-5.0.2]# export ORACLE_HOME=$ORACLE_BASE/product/10.1.0/db_1
[root@FC3 php-5.0.2]# export ORACLE_SID=TEST
[root@FC3 php-5.0.2]# export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
[root@FC3 php-5.0.2]# export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
[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
安装说明:第三到七行其实有些罗嗦了,其目的是控制 root 用户的环境变量,其实也可以直接在 root 用户的.bash_profile文件中制定环境变量。当然了,也可以用 oracle 用户来进行 configure 与 make 。第八行中的 --with-oci8=$ORACLE_HOME 激活 oci8 支持。
接下来需要修改httpd.conf 文件的内容:
[root@FC3 php-
添加如下内容:
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
重新启动 apache:
[root@FC3 ]# /bin/stopapache
[root@FC3 ]# /bin/
测试 PHP 模块
测试 PHP 模块是否已经可用。当然是标准办法,写一个包含如下内容的PHP页面 info.php:
从浏览器中查看该页面输出内容。
注意,该页面中的内容 Configure Command 那一行中的内容是否包括如下内容:
'--with-apxs2=/usr/local/apache/bin/apxs'
'--with-oci8=/u01/app/oracle/product/
注意:在测试之后,出于安全的考虑,请把该文件删除
测试 PHP 的 oci
写一个简单的页面测试 oci 是否可用 (Just a copy sample from OTN):
$db_conn = ocilogon( "scott", "tiger","TEST" );
$cmdstr = "select ename, sal from emp";
$parsed = ociparse($db_conn, $cmdstr);
ociexecute($parsed);
$nrows = ocifetchstatement($parsed, $results);
echo " for ($i = 0; $i { } echo "
echo "Oracle PHP Test
";
echo "\n\
";\n"; \n";
echo "Name \nSalary \n
echo "\n"; \n";
echo "" . $results["ENAME"][$i] . " ";
echo "$ " . number_format($results["SAL"][$i], 2). " ";
echo " Number of Rows: $nrows
echo "
If you see data, then it works!
?>
说明:上例中,scott/tiger分别为数据库的用户名字和密码,TEST为数据库连接串名字。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

PHP has shaped the network over the past few decades and will continue to play an important role in web development. 1) PHP originated in 1994 and has become the first choice for developers due to its ease of use and seamless integration with MySQL. 2) Its core functions include generating dynamic content and integrating with the database, allowing the website to be updated in real time and displayed in personalized manner. 3) The wide application and ecosystem of PHP have driven its long-term impact, but it also faces version updates and security challenges. 4) Performance improvements in recent years, such as the release of PHP7, enable it to compete with modern languages. 5) In the future, PHP needs to deal with new challenges such as containerization and microservices, but its flexibility and active community make it adaptable.
