Solved

PHP5 > Getting OCI8 11g working on Win7 64bit

Posted on 2010-11-17
15
16,059 Views
Last Modified: 2012-05-10
I'm very experienced installing PHP on Windows and Linux.   I'm on Windows 7 Pro 64 bit and I just cannot get OCI8 working!! I can get PHP installed and running  and I've got all the extensions like MySQL running but OCI escapes me.

Here's what I get after unzipping php-5.3.3-Win32-VC9-x86.zip into my programs directory and running command line:
C:\>"C:\Program Files (x86)\PHP\php.exe" -v
PHP 5.3.3 (cli) (built: Jul 21 2010 20:28:30)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

Open in new window


Here's what I get after modifying php.ini with
include_path = "C:\Program Files (x86)\PHP\ext"
extension=php_oci8_11g.dll

C:\>"C:\Program Files (x86)\PHP\php.exe" -v
PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\php5\php_oci8_11g.dll' - The specified module could not be found.  in Unknown on line 0

Open in new window


I have no idea where it's getting the "C:\php5\php_oci8_11g.dll" path.  Confirmed the right php.ini is getting parsed by running c:\>php -i which shows
Configuration File (php.ini) Path => C:\Windows
Loaded Configuration File => C:\Program Files (x86)\PHP\php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)

Open in new window


So giving up on PHP5.3.3.  Now I extracted php-5.2.14-Win32-VC6-x86.zip. And running the below command with no extensions loaded everything works great:
C:\>"C:\Program Files (x86)\PHP\php.exe" -v
PHP 5.2.14 (cli) (built: Jul 27 2010 10:43:58)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies

Open in new window


Just for kicks, I made only the below two changes to confirm I really could get one extension working:
include_path = "C:\Program Files (x86)\PHP\ext\"
extension=php_mysql.dll

Ans sure enough it still works!
C:\>"C:\Program Files (x86)\PHP\php.exe" -v
PHP 5.2.14 (cli) (built: Jul 27 2010 10:43:58)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies

Open in new window


But now I uncomment the OCI extension:
extension=php_oci8.dll

And I get this:
C:\>"C:\Program Files (x86)\PHP\php.exe" -v
PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\Program Files (x86)\PHP\ext\php_oci8.dll' - %1 is not a valid Win32 application.
 in Unknown on line 0
PHP 5.2.14 (cli) (built: Jul 27 2010 10:43:58)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies

Open in new window


My Windows path looks like this:
C:\>path
PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseSVN\bin;C:\Oracle\in
stantclient_11_2\;C:\Program Files (x86)\PHP\

Open in new window

:

And I have ORACLE_HOME = C:\Oracle\instantclient_11_2\

And SQL*Plus is running just fine:
C:\>sqlplus username/******@hostname.mycompany.com:1521/clrprd

SQL*Plus: Release 11.2.0.1.0 Production on Wed Nov 17 22:29:20 2010

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options

SQL>

Open in new window


I just saw on the first PHP5.3.3 attempt I configured the include_path instead of the ext directory so that's an issue but other than that, what am I missing?  I think PHP 5.2.14 supports Oracle 11.2?
0
Comment
Question by:Geoff Millikan
  • 12
  • 2
15 Comments
 
LVL 13

Assisted Solution

by:dsmile
dsmile earned 100 total points
ID: 34161950
You need to add /bin of your Oracle to windows path too. (/bin means where Oracle's dlls are located)


ext\php_oci8.dll is just a wrapper of Oracle's library, so you need to include that library into include path of PHP.
0
 
LVL 48

Accepted Solution

by:
hernst42 earned 400 total points
ID: 34162006
Get the process monitor from http://technet.microsoft.com/de-de/sysinternals/bb896645.aspx, start it, execute php -m and then look where the php.exe is looking for the libraries and which libraries are not found. Esle use the Zend Server CE which comes with a working version out of the box for oci8.
0
 

Author Comment

by:Geoff Millikan
ID: 34162055
So you guys are thinking the below error is because PHP cannot find some Oracle library?
Unable to load dynamic library 'C:\Program Files (x86)\PHP\ext\php_oci8.dll' - %1 is not a valid Win32 application.
 in Unknown on line 0

Open in new window


If there was a problem with an Oracle library I would expect SQL*Plus to crash - but it works fine.  I'll try the debugging route.  This is terrible.
0
 
LVL 13

Expert Comment

by:dsmile
ID: 34162191
Well, t1shopper, SQL*Plus won't crash, but PHP might because Apache cannot load required library.

Try as I said, restart your computer then try again.
If the error still occurs, we'll look further into it
0
 

Author Comment

by:Geoff Millikan
ID: 34164753
dsmile: I'm not using Apache.

I think I might know what it is.  I'm using 64bit edition of SQLPlus.  I'll be the 32bit PHP wrapper cannot talk to the 64bit Oracle libraries....

Stand by please...
0
 

Author Comment

by:Geoff Millikan
ID: 34166619
Per this post, it looks like maybe the 32 vs 64bit doesn't seem like an issue (but it might still be):
http://forums.oracle.com/forums/thread.jspa?threadID=490845

The stack trace (holy cow, I had no idea there were that many events happening on my box!!!) shows that like the above links talks about, PHP is looking for several DLL files that are missing.  The trace also showed *lots* of hits to the Windows registry for things that were not present, too many to list.  Here's the missing files:
9:25:00.1959825 AM	php.exe	6512	CreateFile	C:\Program Files (x86)\PHP\WSOCK32.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
9:25:00.1980134 AM	php.exe	6512	CreateFile	C:\Program Files (x86)\PHP\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
9:25:00.1981595 AM	php.exe	6512	CreateFile	C:\Windows\SysWOW64\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
9:25:00.1983059 AM	php.exe	6512	CreateFile	C:\Windows\system\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
9:25:00.1984555 AM	php.exe	6512	CreateFile	C:\Windows\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
9:25:00.1986019 AM	php.exe	6512	CreateFile	C:\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
9:25:00.1987460 AM	php.exe	6512	CreateFile	C:\Windows\SysWOW64\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
9:25:00.1988918 AM	php.exe	6512	CreateFile	C:\Windows\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
9:25:00.1990372 AM	php.exe	6512	CreateFile	C:\Windows\SysWOW64\wbem\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
9:25:00.1992925 AM	php.exe	6512	CreateFile	C:\Windows\SysWOW64\WindowsPowerShell\v1.0\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
9:25:00.1994372 AM	php.exe	6512	CreateFile	C:\Program Files\TortoiseSVN\bin\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
9:25:00.1996264 AM	php.exe	6512	QueryBasicInformationFile	C:\Oracle\instantclient_11_2\oci.dll	SUCCESS	CreationTime: 3/30/2010 6:03:20 AM, LastAccessTime: 3/30/2010 6:03:20 AM, LastWriteTime: 3/30/2010 6:03:20 AM, ChangeTime: 11/13/2010 2:15:01 AM, FileAttributes: A
9:25:00.2002978 AM	php.exe	6512	CreateFile	C:\Program Files (x86)\PHP\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
9:25:00.2056044 AM	php.exe	6512	CreateFile	C:\Program Files (x86)\PHP\DNSAPI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
9:25:00.2118154 AM	php.exe	6512	CreateFile	C:\Program Files (x86)\PHP\rasadhlp.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

Open in new window

0
 

Author Comment

by:Geoff Millikan
ID: 34166818
I copied the DLL files that were in other places into the PHP directory.  But PHP really seems to want an OCI.DLL file which it finds in C:\Oracle\instantclient_11_2\oci.dll below however in the second code block you can see it keep looking for an OCI.DLL everywhere else!  So that makes me thing it doesn't like the  C:\Oracle\instantclient_11_2\oci.dll file but there's no indication of that.
10:41:25.0837422 AM	php.exe	6964	QueryBasicInformationFile	C:\Program Files (x86)\PHP\ext\php_oci8.dll	SUCCESS	CreationTime: 11/17/2010 10:17:12 PM, LastAccessTime: 11/17/2010 10:17:12 PM, LastWriteTime: 7/27/2010 10:45:36 AM, ChangeTime: 11/17/2010 10:17:12 PM, FileAttributes: ANCI
10:41:25.0866207 AM	php.exe	6964	QueryBasicInformationFile	C:\Oracle\instantclient_11_2\oci.dll	SUCCESS	CreationTime: 3/30/2010 6:03:20 AM, LastAccessTime: 3/30/2010 6:03:20 AM, LastWriteTime: 3/30/2010 6:03:20 AM, ChangeTime: 11/13/2010 2:15:01 AM, FileAttributes: A

Open in new window


And here it goes lookign everywhere else for another OCI.DLL file...
10:41:25.0547937 AM	php.exe	6964	CreateFile	C:\Windows\System32\wow64log.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
10:41:25.0605222 AM	php.exe	6964	CreateFile	C:\Program Files (x86)\PHP\ODBC32.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
10:41:25.0757087 AM	php.exe	6964	QueryDirectory	C:\Windows\php-cli.ini	NO SUCH FILE	Filter: php-cli.ini
10:41:25.0844156 AM	php.exe	6964	CreateFile	C:\Program Files (x86)\PHP\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
10:41:25.0845645 AM	php.exe	6964	CreateFile	C:\Windows\SysWOW64\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
10:41:25.0848273 AM	php.exe	6964	CreateFile	C:\Windows\system\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
10:41:25.0849741 AM	php.exe	6964	CreateFile	C:\Windows\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
10:41:25.0851202 AM	php.exe	6964	CreateFile	C:\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
10:41:25.0852649 AM	php.exe	6964	CreateFile	C:\Windows\SysWOW64\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
10:41:25.0854124 AM	php.exe	6964	CreateFile	C:\Windows\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
10:41:25.0855681 AM	php.exe	6964	CreateFile	C:\Windows\SysWOW64\wbem\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
10:41:25.0859763 AM	php.exe	6964	CreateFile	C:\Windows\SysWOW64\WindowsPowerShell\v1.0\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
10:41:25.0864304 AM	php.exe	6964	CreateFile	C:\Program Files\TortoiseSVN\bin\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
10:41:25.0871897 AM	php.exe	6964	CreateFile	C:\Program Files (x86)\PHP\OCI.dll	NAME NOT FOUND	Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
10:41:25.1315619 AM	php.exe	6964	Process Exit		SUCCESS	Exit Status: 0, User Time: 0.0156001 seconds, Kernel Time: 0.0780005 seconds, Private Bytes: 2,916,352, Peak Private Bytes: 6,119,424, Working Set: 5,799,936, Peak Working Set: 7,868,416

Open in new window

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:Geoff Millikan
ID: 34166840
The stack trace is pretty impressive debugging tool, there's the link for the English version:
http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx
0
 

Author Comment

by:Geoff Millikan
ID: 34166882
0
 

Author Comment

by:Geoff Millikan
ID: 34167020
I think the issue is that PHP isn't liking the OCI.DLL from the Oracle library...

"The pre-built Windows php_oci8.dll and php_pdo_oci.dll DLLs need Oracle 10.2 client libraries or greater. The php_oci8_11g.dll needs Oracle 11.1 client libraries or greater." - http://wiki.oracle.com/page/PHP+Oracle+FAQ

On PHP 5.2.8, "It's not enough to have an oracle 10g client installed, it must be the right version of the 10g client!!" - http://forums.devnetwork.net/viewtopic.php?t=105918


"I figured it out! The version of oci.dll I had (v8.1.7.0.0) was NFG, despite
my research to the contrary. I went to http://www.oracle.com today, and got the
latest version of this file (v10.2.0.1) and it worked BEAUTIFULLY! Heh, so
very happy!" - http://www.mombu.com/php/php/t-php-oci8dll-works-but-ocidll-doesnt-629464.html
0
 

Author Comment

by:Geoff Millikan
ID: 34167504
Dang.

C:\>"C:\Program Files (x86)\PHP\php.exe" -v
Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files (x86)\PHP\ext\php_oci8_11g.dll' - %1 is not a valid Win32 application.
 in Unknown on line 0
PHP 5.3.3 (cli) (built: Jul 21 2010 20:28:30)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

Open in new window


More people with same problem with no resolution:
http://forums.oracle.com/forums/thread.jspa?messageID=4213939
0
 

Author Comment

by:Geoff Millikan
ID: 34167510
Here's someone who got it working, hold please and let me try this:

http://forums.oracle.com/forums/thread.jspa?messageID=6520262
0
 

Assisted Solution

by:Geoff Millikan
Geoff Millikan earned 0 total points
ID: 34167722
It was the 32 vs 64bit issue as described at the link here:

For the next person here's the steps:
1. Download the 32 bit version instantclient-basic-win32-11.2.0.1.0.zip from http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
2. Unzip into some folder (it can be anything) and add that directory to the Windows PATH statement
3. I changed the environmental variable ORACLE_HOME to point to the same directory as the above.
4. Uncomment the extension=php_oci8_11g.dll  in the php.ini file.

So for me now it looks like the below which is just what we want.  The oci_connect() statement is working! (It's complaining that the sytax isn't right - whihc means it's working - if it wasn't working, it would just say, Unknown Function.):
C:\>path
PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseSVN\bin;C:\Oracle\in
stantclient_11_2_x86\;C:\Program Files (x86)\PHP\

C:\>set ORACLE_HOME
ORACLE_HOME=C:\Oracle\instantclient_11_2_x86\

C:\>"C:\Program Files (x86)\PHP\php.exe" -v
PHP 5.3.3 (cli) (built: Jul 21 2010 20:28:30)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

C:\>"C:\Program Files (x86)\PHP\php.exe" -r "var_dump(oci_connect());"
PHP Warning:  oci_connect() expects at least 2 parameters, 0 given in Command line code on line 1

Warning: oci_connect() expects at least 2 parameters, 0 given in Command line code on line 1
NULL

C:\>

Open in new window


0
 

Assisted Solution

by:Geoff Millikan
Geoff Millikan earned 0 total points
ID: 34167765
"I was having the same problem. It was the Instant Client version I was using. I had to use 32bit, not 64bit (as someone else suggested earlier in this thread)." http://forums.oracle.com/forums/thread.jspa?messageID=4418153

But this thread seems to indicate some method for getting the 64bit library to work:
http://forums.oracle.com/forums/thread.jspa?threadID=1071469

YMMV.
0
 

Author Closing Comment

by:Geoff Millikan
ID: 34195054
The last two comments summarize the solution well IMHO.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now