We’re trying to lift an existing PHP 7.4 app from an internal server running on Windows Server 2012 to an Azure Web App. The PHP app uses OCI8 to connect to an Oracle database. Everything (except the database connection) works fine without the OCI8 extension enabled.
We’ve followed the guide at https://docs.microsoft.com/en-us/archive/blogs/azureossds/access-oracle-databases-from-azure-web-apps-using-oci8-drivers-with-php as recommended in other Stack Overflow Questions, but whenever the OCI8 extension is enabled we get logless HTTP 500 errors.
The steps we take are:
- Starting with OCI8 disabled, the app loads fine but can’t run any database calls. Database call errors are recorded in the logs.
- Edit the D:homesiteiniextensions.ini file to enable OCI8 (we’ve tried multiple variations – full path, 32 bit, 64 bit, extension name only e.g.
extension=php_oci8
– all have the same results). - Restart the app
- Refresh the page – result is status code 500, with a plain white screen reading
The page cannot be displayed because an internal server error has occurred.
- Check everything under D:homeLogFiles, including php_errors.log, eventlog.xml, and /http/RawLogs. eventlog.xml shows the server reboot, nothing else is recorded after that.
We have also tried using the “App Service Logs” in the Azure App Service, and enabling Application Insights, but there was similarly nothing of interest (we could see the HTTP 500 response in the logs, but not any details about what caused it).
The suspicion is that PHP isn’t starting, but we aren’t sure how to trace that when nothing seems to be logged.
Ultimately, that leads to this being two questions:
- Is there perhaps a different way to enable logs in the Azure App Service, or a log location I might be missing?
- Is there an updated guide available for running a PHP app with OCI8 on Azure App Service? The guide above is 5+ years old, and at a minimum the versions of everything listed in it appear to be outdated. I suspect the Azure App Service has updated in a way that might be blocking us too.
Thanks!
UPDATE 2021-08-10
Turns out this issue was due to an incompatibility between the App Service “Composer” extension and OCI8. I’ll continue to update this post with progress as we get that enabled, since I assume others will run into this at some point as well.
UPDATE 2021-08-16
Just as a final update, we wound up with an old version of Composer installed (1.6.4). We didn’t test all the other versions, but if you run into the same issue 1.6.4 can at least act as a solid baseline.
The Azure Extension’s repo doesn’t appear to specify a version, so it should grab the latest, but it seems only 1.8.5 gets installed so there might be a bad cache somewhere. TL;DR: If you encounter issues, try manually installing Composer instead of using the Extension.
Advertisement
Answer
I did some searching, this one seems like a pretty solid and more recent answer: Does Azure PHP 7 web app have Oracle drivers?.
I think you’re probably right that PHP isn’t starting correctly. A few questions:
- Did you configure and toggle on PHP error logging for the site like described here: https://azureossd.github.io/2016/09/28/how-to-identifyreview-errors-on-php-applications-in-azure-web-apps-using-log-stream-service/
- If you create a phpinfo.php file in /wwwroot/ containing
<?php phpinfo();
, and try to access it while the issue is happening, does oci8 driver load? - If you create and try to access a static file like index.html while the issue is happening, can it be accessed directly? It would confirm the PHP issue.
- Can you check the post with the proper screenshots, maybe it will help be more clear what is missing, the link referenced above drops the screenshots: https://azureossd.github.io/2016/02/23/access-oracle-databases-from-azure-web-apps-using-oci8-drivers-with-php/ (I followed the steps here to a T and it worked for me)
I built a lab, it took me a little work, but I actually got it running so it seems. I could build an Oracle server and fetch some data to prove it works:
I’d probably follow those steps above and I am sure it can be figured out. It’s probably missing one of these steps:
- Needs App Setting PHP_INI_SCAN_DIR
- Need the /site/ini/extensions.ini file with the proper setting, I used this: extension=”D:Program Files (x86)PHPv7.4extphp_oci8_12c.dll”
- Needs the ApplicationHost.xdt with the proper setting
- Need to download and upload the Oracle Instant Client folder I uploaded instantclient_19_11 but you could probably just as well upload instantclient_12_X
- Restart after you get these all in place and confirm the OCI8 driver loaded. I was seeing a similar white error page up until I had all of these proper.