Python 如何为 py3 安装和配置 mod_wsgi

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19344252/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 13:31:37  来源:igfitidea点击:

How to install & configure mod_wsgi for py3

pythonapachepython-3.xapache2mod-wsgi

提问by Lazik

I installed & configured mod_wsgi for python2.7 but now I would also like to have mod_wsgi for py3

我为 python2.7 安装并配置了 mod_wsgi 但现在我也想为 py3 安装 mod_wsgi

I'm in ubuntu 12.04 My apache conf file looks like this for py2.7 :

我在 ubuntu 12.04 我的 apache conf 文件对于 py2.7 如下所示:

<Directory /var/www/vhosts/my_web>
    WSGIProcessGroup my_web
    WSGIApplicationGroup %{GLOBAL}
    Order deny,allow
    Allow from all
</Directory>

Now I would like to install mod_wsgi for python3.

现在我想为python3安装mod_wsgi。

I think I have to do apt-get install libapache2-mod-wsgi-py3

我想我必须做 apt-get install libapache2-mod-wsgi-py3

But I can't find any instruction on how to configure mod_wsgi for py3. a) Can I keep mod_wsgi for py2.7 or do I need to remove it for apache to work with mod_wsgi_py3? b) What do I need to include in my apache conf?

但是我找不到有关如何为 py3 配置 mod_wsgi 的任何说明。a) 我可以保留 py2.7 的 mod_wsgi 还是我需要删除它以便 apache 与 mod_wsgi_py3 一起使用?b) 我需要在我的 apache conf 中包含什么?

采纳答案by davesave

sudo apt-get install libapache2-mod-wsgi-py3

sudo apt-get install libapache2-mod-wsgi-py3

This will replace libapache2-mod-wsgi and will restart the apache service.

这将替换 libapache2-mod-wsgi 并将重新启动 apache 服务。

More specific instructions (Django) are available for here: https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/modwsgi/

更具体的说明(Django)可在此处获得:https: //docs.djangoproject.com/en/1.8/howto/deployment/wsgi/modwsgi/

回答by Arthur M

It is incorrect to say you do not need to install it again. Graham Dumpleton (the author of the mod_wsgi module) addressed the issue here.

说您不需要再次安装它是不正确的。Graham Dumpleton(mod_wsgi 模块的作者)在这里解决了这个问题。

Short answer - you will need to install the mod_wsgi compiled for your updated Python. I had the very same issue - as far as I can remember you need to get the correct pip for your Python version and run something along the lines of this:

简短回答 - 您需要安装为更新的 Python 编译的 mod_wsgi。我遇到了同样的问题 - 据我所知,您需要为您的 Python 版本获取正确的 pip 并按照以下方式运行:

sudo pip3.x install --target=/path/to/python3.x/site-packages mod_wsgi

回答by boatcoder

If you are using virtualenvs (which you should) you would simply build one out for the version of python you want to build mod_wsgi for.

如果您正在使用 virtualenvs(您应该使用),您只需为要为其构建 mod_wsgi 的 python 版本构建一个。

$ mkvirtualenv --python=/usr/bin/python3 myvenv

Then

然后

(myvenv) $ pip install mod_wsgi 

will build a Python3 version for you.

将为您构建一个 Python3 版本。