matf matf - 4 months ago 53
Apache Configuration Question

Apache 2.4 - how to set PATH environment variable on Windows

How can I change PATH environment variable for Apache 2.4 process on Windows ?
I want to be able to load mod_wsgi with custom Python distribution bundled with application installer. Right now it only loads if Python was installed separately and python dll is already in Windows/system32 folder.

I don't want to modify system PATH variable.

According to this documentation:

SetEnv should be allowed to set PATH in Apache 2.4 but it does not seem to work for me. Windows event viewer shows "Cannot load modules/ into server: The specified module could not be found". It only works if python27.dll is already present in Windows/system32.


If the Python DLL is not in the PATH and can't be added there, you can add to the Apache configuration file:

LoadFile C:/Python27/libs/python27.lib

This must be before the LoadModule line for the wsgi_module.

You may also need to set:

WSGIPythonHome C:/Python27

where the argument is the value of sys.prefix for the Python installation.

The later is needed if Python when being initialised from within mod_wsgi can't find where the Python installation was.