0

我必须升级使用 PHP 5.3 32 位、Apache2.2 32 位、Oracle 客户端 11.2 32 位在 Windows 64 位上运行的旧运行和功能应用程序(Win10 用于开发,服务器用于生产)。

新堆栈是 Apache2.4 32 位、PHP8 32 位和完全相同的 Oracle 客户端 11.2 32 位。

当我运行 webapp 时,我在第一次尝试连接数据库时遇到了这个错误:

Fatal error: Uncaught Error: Call to undefined function oci_connect() in c:\some\path\connexion_check.php:16 Stack trace: #0 {main} thrown in c:\some\path\connexion_check.php on line 16

我的安装是使用这些软件包完成的:

  • httpd-2.4.48-win32-VS16.zip
  • php-8.0.8-Win32-vs16-x86.zip
  • php_oci8-3.0.1-8.0-ts-vs16-x86.zip
  • php-debug-pack-8.0.8-Win32-vs16-x86.zip

在我的 PHP.ini 文件中,我设置了

extension_dir = "ext"
extension=oci8_11g 

在那里,我使用与 PHP5.3 => extension=oci8_11g 相同的参数,但 DLL 使用包 php_oci8-3.0.1-8.0-ts-vs16-x86.zip 进行了更新

运行命令php --ri oci8

oci8

OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 3.0.1
Oracle Run-time Client Library Version => 11.2.0.3.0
Oracle Compile-time Instant Client Version => 11.2

Directive => Local Value => Master Value
oci8.max_persistent => -1 => -1
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
oci8.default_prefetch => 100 => 100
oci8.old_oci_close_semantics => Off => Off
oci8.connection_class => no value => no value
oci8.events => Off => Off

Statistics =>
Active Persistent Connections => 0
Active Connections => 0

一些 PHPINFO(来自 CLI)

phpinfo()
PHP Version => 8.0.8

System => Windows NT D20899 10.0 build 19042 (Windows 10) i586
Build Date => Jun 29 2021 15:54:30
Build System => Microsoft Windows Server 2019 Datacenter [10.0.17763]
Compiler => Visual C++ 2019
Architecture => x86
Configure Command => cscript /nologo /e:jscript configure.js  "--enable-snapshot-build" "--enable-debug-pack" "--with-pdo-oci=..\..\..\..\instantclient\sdk,shared" "--with-oci8-19=..\..\..\..\instantclient\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--without-analyzer" "--with-pgo"
Server API => Command Line Interface
Virtual Directory Support => enabled
Configuration File (php.ini) Path =>
Loaded Configuration File => C:\www\php8\php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
PHP API => 20200930
PHP Extension => 20200930
Zend Extension => 420200930
Zend Extension Build => API420200930,TS,VS16
PHP Extension Build => API20200930,TS,VS16
Debug Build => no
Thread Safety => enabled
Thread API => Windows Threads
Zend Signal Handling => disabled
Zend Memory Manager => enabled
Zend Multibyte Support => disabled
IPv6 Support => enabled
DTrace Support => disabled

Registered PHP Streams => php, file, glob, data, http, ftp, zip, compress.zlib, compress.bzip2, https, ftps, phar
Registered Stream Socket Transports => tcp, udp, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2, tlsv1.3
Registered Stream Filters => convert.iconv.*, string.rot13, string.toupper, string.tolower, convert.*, consumed, dechunk, zlib.*, bzip2.*

This program makes use of the Zend Scripting Language Engine:
Zend Engine v4.0.8, Copyright (c) Zend Technologies
    with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans

除了这个 webapp,我还使用相同的 InstantClient 安装管理/使用连接到我的 Oracle DB 的其他应用程序/工具。从这台计算机可以使用以下数据库连接:

  • 甲骨文工具
  • Powerbuilder 32位
  • Python 32 位 + cx_Oracle
  • Microsoft Word 通过 Oracle Data Provider for .NET 和 OLEDB

我检查了很多东西,但无法弄清楚出了什么问题。谢谢你的帮助 :-)

编辑:

C:\www\php8>php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
filter
hash
iconv
json
libxml
mysqlnd
oci8
openssl
pcre
PDO
Phar
readline
Reflection
session
SimpleXML
SPL
standard
tokenizer
xdebug
xml
xmlreader
xmlwriter
zip
zlib

[Zend Modules]
Xdebug
4

1 回答 1

0

见鬼,我明白了。这是下一个遇到同样问题的人的解释......

这是有关我的设置的一些数据:

  • C:\万维网\
  • C:\WWW\Apache24
  • C:\万维网\PHP8
  • C:\WWW\PHP8\php.exe
  • C:\WWW\PHP8\php.ini
  • C:\WWW\PHP8\ext
  • C:\WWW\PHP8\ext\oci8_11g.dll
  • C:\WWW\MyWebApp\index.php

扩展 oci8 不是来自 phpinfo() 似乎很奇怪。使用Process Monitor我发现 oci8_11g.dll 到处都被搜索(根据 PATH 环境变量),但不是在正确的位置。

我在 PHP.INI 中的设置是这样的:

extension_dir = ".\ext"

ProcMon 显示 C:\WWW\PHP8\ext 没有被搜索到,而是 C:\WWW\Apache24\ext。

因此,我了解到文件夹.\ext与从 C:\WWW\Apache24\bin 运行的 Apache httpd.exe 进程相关

因此,在我的 PHP.ini 文件中,我将值更改为绝对路径,以便它在 CLI 环境以及从 Apache 启动的 PHP 中兼容。

extension_dir = "c:\www\php8\ext"

重启 Apache 服务后,一切正常。

于 2021-07-01T13:28:53.423 回答