[转载]Apache2.2 + PHP5.3.2 + Oracle 10g配置

baacloud免费翻墙vpn注册使用

[转载]【Vegas原创】Apache2.2 + PHP5.3.2 + Oracle 10g配置 – ☆心海e站☆ – 博客园.

1,下载apache2.2 和 php5.3.2

2,安装apache。我装的是httpd- 2.2.15-win32-x86-openssl-0.9.8m-r2.msi,装的时候记得更改apache安装目录【这对后续更改apache配置 文件的效率会更高】 以及端口。 默认的端口是80 。 如果装了iis,记得更改其他的端口。

3, 安装php5.3.2。我装的是php-5.3.2-Win32-VC6-x86.zip这个文件。解压到一个方便的目录下。我解压到了D:\php文件 夹下。

4, 将“php.ini-developer”更名为“php.ini”。

5,修改php.ini:

1),extension_dir路径改为:D:\php\ext

image

2),查找oracle 的extension,将前面的分号去掉:

image

6, 配置apache支持php。找到apache安装目录,conf文件夹下的httpd.conf文件,打开:

1)设置起始页:

<IfModule dir_module>
DirectoryIndex index.html
</IfModule>

2)配置php:在#LoadModule vhost_alias_module modules/mod_vhost_alias.so后,添加:

# For PHP 5 do something like this:
LoadModule php5_module “D:/php/php5apache2_2.dll”
AddType application/x-httpd-php .php
AddType application/x-httpd-php .htm .html
# configure the path to php.ini
PHPIniDir “D:/php/”

image

3)修改根目录(类似 iis的站点根目录):

DocumentRoot 修改为:DocumentRoot “D:/htdocs”

image

Directory修改为:

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory “D:/htdocs”>
#
# Possible values for the Options directive are “None”, “All”,
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that “MultiViews” must be named *explicitly* — “Options All”
# doesn’t give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be “All”, “None”, or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
AllowOverride None

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

</Directory>

image

4)保存 httpd.conf文件

7,在D:\htdocs 新建一个index.html,内容如下:

<html>
<body>

<?php

if ($c=OCILogon("nhi", "nhi", "hisdb"))   //如果连接成功
    {
        echo "Successfully connected to Oracle.\n";

        $query = 'select name,open_mode from v$database';  //查询显示
        $stid = oci_parse($c, $query);
        $r = oci_execute($stid);


        // Fetch the results in an associative array
        print '&lt;table border="1">';
        while ($row = oci_fetch_array($stid, OCI_RETURN_NULLS+OCI_ASSOC)) {
           print '<tr>';
           foreach ($row as $item) {
              print '<td>'.($item?htmlentities($item):' ').'</td>';
           }
           print '</tr>';
        }
        print '</table>';

        ocilogoff($c);                               //关闭连接
    }
else                                                //否则显示错误
    {
        $err = OCIError();
        echo "Oracle Connect Error " .$err;
    }

phpinfo();                                         //显示php信息

?>

</body>
</html>

8,打开http://localhost ,查看:

image

赞(0) 打赏
分享到: 更多 (0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏