WSGI apps with python 2 and python 3 on the same server?
Asked Answered
P

3

6

I already have a web application in written in Python 2 that runs over WSGI (specifically, OpenERP web server).

I would like to write a new web application that would run on the same server (Apache 2 on Ubuntu), but using WSGI and Python 3. The two applications would be on different ports.

Is that possible?

Parol answered 17/1, 2013 at 9:9 Comment(0)
P
1

No, it is not possible with mod_wsgi (see here: https://github.com/GrahamDumpleton/mod_wsgi/issues/21 and here: https://serverfault.com/questions/599859/multiple-python-versions-under-apachemod-wsgi)

This post also provides an alternative: using nginx.

Pipes answered 4/5, 2017 at 16:22 Comment(1)
I can confirm this is impossible. My server is running mezzanine cms with python 2. I was trying to deploy other cms - djangcms - with python3 and it was unable to run.Dusen
T
1

Yes, this is possible as far as you are using virtual environment.

Please refer this : https://pypi.org/project/mod-wsgi/

After following these steps you may need to use ProxPass in your apache config file.

For that follow this : Apache redirect to another port

Turkoman answered 24/8, 2022 at 16:35 Comment(1)
Self contained answer would be better than links as links could die in the futureMegasporangium
H
-1

Its quite possible. This is what virtualenv as all about. Set up the second app in a virtualenv , with python3 .

You an add it in a virtualhost configuration in apache.

Hazy answered 17/1, 2013 at 9:29 Comment(2)
Many thanks, that's great to know. However, although I can see I can have links to different .wsgi scripts in this way, I'm still a little confused about how mod_wsgi is added to Apache. If I've understood correctly (and I may not have done!), then mod_wsgi itself needs to be compiled for either python 2 or python 3. Is that correct? And if so, does that mean I somehow need to have 2 versions of mod_wsgi installed? Can I do that using virtualenv too?Parol
Virtualenv won't be enough, as mod_wsgi is compiled either for Python2 or Python3, but cannot work with both. The location of Python does not matter.Pipes

© 2022 - 2024 — McMap. All rights reserved.