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

mod_wsgi for Python 2 as well as Python 3 on one Apache server. #21

proycon opened this Issue Jul 1, 2014 · 3 comments


None yet
3 participants

proycon commented Jul 1, 2014

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?


This comment has been minimized.


GrahamDumpleton commented Jul 1, 2014

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.


This comment has been minimized.

BtbN commented Nov 3, 2014

Wouldn't it be possible to just add a compile-time configurable suffix to all config directives, or does loading python2 and 3 into the same application alone cause trouble?


This comment has been minimized.


GrahamDumpleton commented Nov 3, 2014

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.

clrpackages pushed a commit to clearlinux-pkgs/mod_wsgi that referenced this issue Oct 11, 2017

mod_wsgi: Autospec creation for version 4.5.20
Revert back to use Python 2 instead of Python 3. This enables running
Koji in Clear Linux again.

The module can't handle both versions of Python, details in
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment