-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use multiple mod_wsgi installed with pip install in different virtual environments #882
Comments
The only thing that would usually be in the wsgi.load file is the loading of the mod_wsgi.so file. There can only be one mod_wsgi.so file loaded for the whole of Apache. You cannot load it multiples times and if you do only the first is used. Also be aware that one Apache instance can only be used with one Python X.Y.Z version at a time. You cannot have virtual environments using different Python versions. So the wsgi.load file should load a mod_wsgi.so file compiled against the specific X.Y.Z Python version. All that matters at this point is that it is the same X.Y.Z version that all virtual environments should use. Next is that configurations for different Python WSGI applications would be in their respective VirtualHost definitions (not the wsgi.load file). Because you are having multiple Python WSGI applications, you should use mod_wsgi daemon mode and each VirtualHost or WSGI application should be delegated to use their own mod_wsgi daemon process group. It is at the same time strongly recommended to disable mod_wsgi embedded mode, which is done by adding:
to the end of the wsgi.load file. By disabling embedded mode, it will highlight by way of errors when you screw up the configuration and don't properly delegate WSGI applications to different mod_wsgi daemon process groups. Now when defining each mod_wsgi daemon process group, specify Ensure you use WSGIProcessGroup or the process-group option of WSGIScriptAlias directive to delegate the WSGI application to its intended daemon process group. Since you would only have one WSGI application per daemon process group, ensure you force the use of the main Python interpreter context by using So in summary:
|
Thanks a lot for your detailed response ! It's very clear. Adding "WSGIRestrictEmbedded On" was a game changer. it was really hiding issues. I had gotten everything else correct and my issue was that the home directory needed to have +x permission (which is by default on ubuntu 20.04 but not 22.04. I run the daemon with user "ubuntu" but apparently apache needs some other permission for his own user. |
Hi,
I have multiple projects using django with different virtual environnements (one for each project) and am trying to figure out how to use multiple mod_wsgi installed with pip install (one for each project / venv).
I'm reading the docs from pypi and in this other issue where it's said to "Copy that into the system Apache to load mod_wsgi. Then configure Apache to load your WSGI application."
I'm using ubuntu and usually to activate a module there is a file (/etc/apache2/mods-available/wsgi.load) to load the mod_wsgi.so file, but if I have different venvs, I'll have different mod_wsgi.so files to load (one for each venv). Should I put multiple lines (one for each) in the file ?
I can't find this case in the docs.
Thanks in advance
The text was updated successfully, but these errors were encountered: