Question

I am in the process of enabling OCI8 for PHP to be used with Apache.

I have been getting errors similar to:

PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\php-5.5\ext\php_oci8.dll'

Fatal error: Call to undefined function oci_connect() in ...



So Far

I have set my System Environment Variable PATH to include the paths containing php, php ext, and my instantclient for oracle (worth noting that the instantclient files are on a network shared drive).

Then, I used Process Monitor to see exactly what is going on when Apache loads and i found the lines concerning OCI.DLL (part of the oracle client).


Process Monitor shows:
OCI.dll is not being loaded. Each attempt at loading it shows the file not being found with the "result" column showing "NAME NOT FOUND"
OCI.dll is being looked for within each of the PATH variable paths EXCEPT for my shared drive location, which in this case is Q:/something/something...
I thought this was a bit odd so I changed the "Q" to use a UNC path (knowing that system environment variables do not officially support UNC path). When I checked it again with Process Monitor, it showed that it was looking for OCI.dll in the UNC path but it comes back as "ACCESS DENIED" (but I can access, edit, and delete the file myself).


Summary from Process Monitor:

C:/something/...

Checks each one of my directories IN THE ORDER they are listed in the PATH variable (but none of them contain OCI.dll, as expected).

Q:/something/...

Does not even show up as looking within this directory. I have multiple Q drive paths in my PATH variable and none of them shows up in Process Monitor as being checked.

\\someserver\something\...

Shows up as a record in Process Monitor but the "result" column comes back as "ACCESS DENIED"


Question

  • Why does it not use the PATH locations when the drive letter is associated with a network shared drive? (I have used the same exact path setting to enable the use of the same exact instantclient files for use with VBA and it worked just fine)
  • Why does it tell me that it cannot access the file in the UNC path when I have read/write access to the files?
Was it helpful?

Solution

If you are running Apache as a service then, by default, it runs as NT AUTHORITY\SYSTEM, not the currently logged in user. The rest of my answer follows this assumption.

OCI.dll is not being loaded. Each attempt at loading it shows the file not being found with the "result" column showing "NAME NOT FOUND" OCI.dll is being looked for within each of the PATH variable paths EXCEPT for my shared drive location, which in this case is Q:/something/something...

Q: is a mapped drive for your user account, not the SYSTEM account, so as far as Apache is concerned that path doesn't exist at all.

I thought this was a bit odd so I changed the "Q" to use a UNC path (knowing that system environment variables do not officially support UNC path). When I checked it again with Process Monitor, it showed that it was looking for OCI.dll in the UNC path but it comes back as "ACCESS DENIED" (but I can access, edit, and delete the file myself).

By using a UNC path the local SYSTEM account can now see the location but is not authorised to it, hence the ACCESS IS DENIED message.

So the answer to both of your questions is that the account being used to run Apache is not your user account and doesn't have the same environment settings and access rights.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top