Call to undefined function ocilogon() - IIS 7.5 - Windows 2008 R2 x64 - PHP 7.2.7

跟風遠走 提交于 2021-01-28 11:12:52

问题


I am migrating a website from a development environment (Angular 4 - WAMP Server - PHP 5.6.35) to a production environment. In development, the Angular 4 application was successfully able to connect to a PHP script and run an Oracle stored procedure so there are no issues with the code.

In production, I've had to install PHP using the Web Platform Installer to successfully run a PHP site with phpinfo() showing 'PHP Version 7.2.7'. I run the application and when it attempts to run the PHP script, I get a 500 Internal Server error when the script is run. PHP error logs show:

<b>Fatal error</b>:  Call to undefined function ocilogon() in <b>C:\inetpub\wwwroot\app\assets\scripts\php\pullData.php</b> on line <b>154</b><br />

Research has indicated that the issue could be:

  1. Possible IIS configuration issue
  2. Oracle Instant Client issue
  3. OCI8 PHP Library not enabled

I think I've ruled out the IIS configuration as the front-end connects to PHP and runs the scripts without issue.

Oracle Instant Client 12.1 is installed and other applications can connect to Oracle. The PATH environment variable appears correctly set. I don't know if it is a 32-bit or 64-bit version - or whether this makes a difference.

I think this is the issue - the OCI8 library isn't enabled correctly. On the dev server, I was able to modify the php.ini file to uncomment (and enable) the dll, and phpinfo() showed the OCI8 library in the list:

extension=php_oci8_12c.dll  ; Use with Oracle Database 12c Instant Client

On production, I've had to manually add the 'extension=php_oci8_12c.dll' line (it wasn't uncommented out) and I've checked the EXT folder of PHP and the dll exists there. Phpinfo() still doesn't show the OCI8 library enabled.


回答1:


Issue is fixed, and I took the following steps to fix it:

  1. Uninstalled PHP (removed all PATH references and folders).
  2. Uninstalled Oracle Instant Client using Oracle Universal Installer.
  3. Installed PHP for IIS Express (and all dependencies) using the IIS Web Platform Installer.
  4. Installed Oracle Instant Client 12c using automatic installer (winx64_12102_client.zip), not ZIP file. This way I didn't have to manually add PATH variables etc.
  5. Checked PHP version (and if it was thread safe) using phpinfo(). Thread safety was (is) disabled. Downloaded the non-thread-safe (nts) version of php_oci8_12c.dll from windows.php.net (https://windows.php.net/downloads/pecl/releases/oci8/2.1.8/) and copied contents to EXT folder in the PHP install directory (which was in a parent folder of IIS Express).
  6. Edited the PHP.ini files (php.ini-production and php.ini-development and php.ini) to include 'extension=php_oci8_12c.dll' or uncomment "extension=oci8_12c".
  7. Restarted the server (probably unnecessary).
  8. Opened CMD and ran the code 'php --ri oci8' to check OCI8 support is enabled and using the version of Oracle Instant Client that I just installed. Verified this also by using phpinfo().
  9. Done. OCI functions now work.

This was a grueling process because this web server had multiple installs of Oracle Instant Client and the Web Platform Installer for IIS was buggy when installing PHP 5.6 and its dependencies. I was lucky that this time that the installer did not error out with PHP 7.2 as it originally did when installing PHP 5.6.



来源:https://stackoverflow.com/questions/52438327/call-to-undefined-function-ocilogon-iis-7-5-windows-2008-r2-x64-php-7-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!