Sie sind auf Seite 1von 20

How to install Apache/PHP for working with Oracle Database on Win32 Platform

Jan 29, 2002


Teddy
Author's Bio | E-Mail
Copyright (C) 2004 exzilla.net

Purpose:
Describe basic steps for using PHP and Oracle Database on Win32 Platform.

Prerequisites:
Prerequisites:
N/A

Assumption:
- Web Server planed to run on windows2000sp2.
- We tested with Oracle 8.1.7 EE
- Understand PHP OCI8 extension big picture

Attendees:
PHP developer, Oracle Developer

Step-
Step-by-
by-Step Example:
1. Download all stuff
1.1 Download Oracle Software (In case you don't have Oracle Client Software)
1.2 Download Apache for windows
1.3 Download PHP Engine and library files.

2. Install all stuff


2.1 Install Oracle Client Software.
2.1.1 Step-by-step to install Client Software
2.1.2 Configure Oracle Client network
2.1.3 Test the Oracle Client connection with your database server

2.2 Install Apache http server for windows


2.2.1 Step-by-step to install Apache http Server
2.2.2 Test the Apache http Server

2.3 Install PHP engine


2.3.1 Step-by-step to install PHP engine
2.3.2 Step-by-step to install PHP extension

3. Manual configuration
3.1 Modify httpd.conf apache configuration file.
3.2 Modify php.ini file for enable oci8 extension.
4. Testing
4.1 Startup and shutdown Apache http Server
4.2 Start your first PHP testing program.
4.2 Check your current environment.
4.3 Creation a simple php program for testing oci extension.

1. Download all stuff

1.1 Download Oracle Software (In case you don't have Oracle Client Software)

If you don't have Oracle Client software, you can download all software from "
http://otn.oracle.com/software/content.html " and install it firstly.

1.2 Download Apache for windows

We will start to download Apache http server that is distributed in MSI package.

http://www.apache.org/dist/httpd/binaries/win32/apache_1.3.22-win32-x86.msi

1.3 Download PHP Engine and library files.

And then go to http://www.php.net/downloads.php for downloading windows binary files


of PHP engine.

On downloading page at php.net, you should find 2 separated files.

The first one is PHP 4.0.6 installer, it helps us to install and set a lot of default values.

And the second one is PHP 4.0.6 zip package, it consists of many extensions that we
need to use including oci8 extension.

You should download both files.

After downloading all above files, your hard disk should have the same files as the
following screen.

E:\download\apache>dir
Volume in drive E is E-EXZILLA
Volume Serial Number is 548B-72A7
Directory of E:\download\apache

10/19/2001 03:55p <DIR> .


10/19/2001 03:55p <DIR> ..
10/19/2001 04:22p 2,104,832
apache_1.3.22-win32-x86.msi
10/19/2001 04:36p 4,975,264 php-4.0.6-
Win32.zip
10/19/2001 04:33p 773,192 php406-
installer.exe

3 File(s) 7,853,288 bytes


2 Dir(s) 7,066,619,904 bytes free

E:\download\apache>

2. Install all stuff

2.1 Install Oracle Client

Before starting to install and configure apache/PHP engine, Oracle Client software must
be installed and configured. Then you should use SQL*Plus connecting to database
server from the machine that you
plan to use it as application server.

2.2 Install Apache http Server for windows

2.2.1 Step-by-step to install Apache http Server


2.2.2 Test the Apache http Server

By default, the Apache HTTP Server should be started after finishing installation.
You can access the test page by entering url "http://localhost/" or "http://yourhostname/".

2.3 Install PHP engine

2.3.1 Step-by-step to install PHP engine

Quite easy to install the PHP engine with Windows Installer program
If you have this problem, don't worry; we can manually configure the Apache httpd.conf
file.
Finished installation PHP engine

2.3.2 Step-by-step to install PHP extension

Step to install PHP extension is very easy :) just unzip and copy.

2.3.2.1 Unzip php-4.0.6-Win32.zip to D:\PHP

2.3.2.2 Copy d:\php\php4ts.dll to c:\winnt\system32

D:\PHP>copy php4ts.dll c:\winnt\system32


1 file(s) copied.
D:\PHP>

And it's time to configure the Apache httpd.conf to make PHP work with Apache HTTP
Server

3. Manually configure

3.1 Modify httpd.conf apache configuration file.

Add the following lines to "D:/Program Files/Apache Group/Apache/conf/http.conf" at the


bottom line of that file.

LoadModule php4_module
d:/php/sapi/php4apache.dll
AddType application/x-httpd-php .php

3.2 Modify php.ini file to enable oci8 extension.

Uncomment the php_oci8.dll line in c:\winnt\php.ini

;extension=php_mssql.dll
extension=php_oci8.dll
;extension=php_openssl.dll

Edit extension_dir Location

; Directory in which the loadable


extensions (modules) reside.
extension_dir = "D:\PHP\extensions"

4. Testing

4.1 Startup and shutdown Apache HTTP Server

You can startup and shutdown Apache HTTP Server by using Administrative Tools ->
Services of Windows or use command line as follows.

Starting:
C:\>net stop apache
The Apache service is stopping.
The Apache service was stopped
successfully.
Stopping:
C:\>net start apache
The Apache service is starting.
The Apache service was started
successfully.

4.2 Start your first PHP testing program.

PHP provides very useful function for checking our current environment. You can use
your favorite editor and add 1 line of code in your php source file.

My php file looks like this

C:\> type “D:/Program Files/Apache


Group/Apache/htdocs/fuju/phpinfo.php”
<html>
<body>

<?php
print phpinfo();
?>

</body>
</html>

And then test the above PHP program.

http://fuju.exzilla.com/fuju/phpinfo.php

or

http://localhost/fuju/phpinfo.php

The OCI8 enabled should like this


4.3 Creation a simple php program for testing oci8 extension.

Click here for downloading the sample code for testing oci8 extension

Note:

When you try to start the Apache HTTP server and then get the following error
messages

"The procedure entry point OCILobOpen could not be


located in the dynamic link library OCI.dll."

or

"Unable to load dynamic library


‘D:\PHP\extensions/php_oci8.dll’ – The specified
procedure could not be found."
What's wrong?

You may have wrong version of oci.dll in your PATH environment.

How to solve it?

First choice, you need to put the correct verion of oci.dll (8.1.7) in your currrent PATH
environment.

Second choice, you can copy the correct version of oci.dll from
$ORACLE_HOME/bin/oci.dll (8.1.7) in to APACHE Home.

I use the second choice because I don't need to change path environment that can take
effect to other program that use different oci.dll version.

References:

1. php.net
2. apache.org
3. otn.oracle.com

Das könnte Ihnen auch gefallen