Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
mod_wsgi for Python 2 as well as Python 3 on one Apache server. #21
Currently we run mod_wsgi compiled against Python 2 (installed through the Ubuntu package manager). I just realised the Python 3 package for mod_wsgi can not be installed at the same time because the module name and apache directives would conflict. Is there a possibility to have two versions of mod_wsgi, one for python 2 and one for python3, on the same apache server?
Because Python is embedded within Apache, it can only handle running one version of Python at a time.
Your best bet at this point, as it avoids the pain of having to worry about setting up separate Apache installations yourself, is to use mod_wsgi express (version 4.2.X) to run up two instances of mod_wsgi with different Python versions. Then have Apache, or preferably even nginx, proxy to those two separate mod_wsgi instances.
You can find more details at PyPi:
But in short, the newer version of mod_wsgi can be pip installed into your two separate Python versions and the mod_wsgi-express script then used to start up two separate Apache instances on different ports with your different applications. You don't have to worry about the Apache configuration for these as the mod_wsgi-express script will do it all for you, using a very trimmed down and optimised configuration. You just need to configure the front end web server to proxy to each.
If you want more details I would suggest the mod_wsgi mailing list is the best place to initiate a discussion and I can explain things better there.
No, it cannot be done with how mod_wsgi works at present.
Like you can't have the one command line 'python' executable run code which is a mix of both Python 2 and Python 3 specific code at the same time, you cannot do it with Apache/mod_wsgi either.
To even be able to attempt it would mean a major re-structure of how mod_wsgi works, moving from more of an embedded system to merely a process manager which manages separate Python 2 and Python 3 process. The declining interest in mod_wsgi as a hosting solution doesn't make expending any effort on such a major rewrite to support that as a built in feature worth the trouble.
The better solution as I explained is to use nginx as a front end to proxy to multiple instances of mod_wsgi running on different ports, using mod_wsgi-express to make it all a bit easier.