Reset Apache PATH environment variable in Windows

2.5k views Asked by At

I recently upgraded Apache and PHP due to security, and I also use PHP to communicate with Oracle databases. The new PHP version only has php_oci8_12c.dll module, so I also installed Oracle 12c client.

After I enable the oci8 module, I noticed the module doesn't show up in Apache when I run phpinfo(), but if I run php -m, I find the oci8 module there. Further checking revealed that the PATH environment variable has not been updated since the upgrade, and that the new path only get appended at the end of the PATH variable.

I paste below the (stripped-down) PATH data from Apache:

C:\oracle\client11gR2_32\bin;C:\www\Apache24\bin;C:\www\php548;C:\database\mysql5528\bin;C:\oracle12c\client12c_32\bin;C:\www\php562;C:\www\php562\ext

Compared with system PATH variable:

C:\oracle12c\client12c_32\bin;C:\oracle\client11gR2_32\bin;C:\www\Apache24\bin;C:\www\php562;C:\www\php562\ext;C:\database\mysql5528\bin

I tried restarting the Apache service, and also uninstall/reinstall, but none works. It seems that the data somehow get 'cached' in a separate location, but I can't tell where. If I renamed the Oracle client 11g HOME folder, then the oci8 module is detected and loaded in Apache.

I've searched all around the internet for 'resetting' the Apache PATH variable, but to no avail, therefore I post it here. Please help.

1

There are 1 answers

4
timclutton On BEST ANSWER

There are two possible reasons I can think of:

  1. The path to the 12c client is a user variable, not a system variable (but then I would expect it to be at the end of the path list)
  2. The 12c client installer has directly modified the registry to add the path, and therefore the system environment has not recognised the change yet. (If you are running Apache as a service then just because your account can see the path change doesn't mean the SYSTEM account can see the change.)

Assuming the latter case, a server reboot would fix the problem. If you can't reboot the server then you can try stopping Apache, opening the Environment Variables dialog, and simply pressing OK (on this and all parent dialogs) to 'reinitialise' the system environment. Start Apache again and it should pick up the new setting.


On a related note: You should really replace the bundled OCI driver (1.4.10) with the most recent build from PECL (currently 2.0.8). As stated in the PECL description:

Use the older PHP OCI8 1.4.10 when using PHP 4.3.9 through to PHP 5.1.x, or when only Oracle Database 9.2 client libraries are available.

The Windows download contains php_oci8.dll, php_oci8_11g.dll, and php_oci8_12c.dll. So you wouldn't have needed to try changing the Oracle client installation.