在 Ubuntu 上为 Python3 安装 mod_wsgi [英] Installing mod_wsgi for Python3 on Ubuntu

查看:39
本文介绍了在 Ubuntu 上为 Python3 安装 mod_wsgi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能给我一套在 Ubuntu 上为 Python 3 安装 mod_wsgi 的明确说明?

Could anyone give me a clear set of instructions for installing mod_wsgi on Ubuntu for Python 3?

我确实得到了 Flask &mod_wsgi成功使用Python3,一时觉得很开心.

I did get Flask & mod_wsgi successfully using Python3, and for a brief moment felt happy.

...直到我查看了 Apache 的日志并意识到我遇到了这个问题:https://askubuntu.com/questions/569550/assertionerror-using-apache2-and-libapache2-mod-wsgi-py3-on-ubuntu-14-04-蟒蛇

...until I looked at Apache's log and realised that I've run into this problem: https://askubuntu.com/questions/569550/assertionerror-using-apache2-and-libapache2-mod-wsgi-py3-on-ubuntu-14-04-python

apt-get 正在安装一个过时的 libapache2-mod-wsgi-py3 版本,这会导致 Apache 日志中出现错误.(我应该报告这个问题吗?如果是这样?)

apt-get is installing an out of date version of libapache2-mod-wsgi-py3 and this is causing errors in Apache's log. (Should I report this and if so where?)

在链接中,工程师正在使用 pip 安装更新版本.

In the link, the engineer is using pip to install a more up-to-date version.

有趣的是,他似乎正在将其安装到虚拟 Python3 环境中.(这与使用系统 pip3 有什么不同吗?)

Interestingly, he appears to be installing it into a virtual Python3 environment. (Would this be any different than using the system pip3?)

他也用pip3 install mod_wsgi,但是pip3 search mod_wsgi返回:

(不,他没有,他使用 pip 而不是 pip3.这对吗?他的电线交叉了吗?pip 是不是会忽略他在 py3venv 中的事实,而只是简单地使用系统的 py2 安装?但无论如何这并不能解决混淆...)

mod_wsgi-metrics          - Metrics package for Apache/mod_wsgi.
cykooz.recipe.pastewsgi   - Buildout recipe to create paste.deploy entry points for mod_wsgi or uwsgi
mod_wsgi-httpd            - Installer for Apache httpd web server.
apachemiddleware          - Useful Python middleware for use with mod_wsgi deployments
tranchitella.recipe.wsgi  - Buildout recipe to create paste.deploy entry points for mod_wsgi
mod_wsgi                  - Installer for Apache/mod_wsgi.

那么什么是mod_wsgi-httpd?确定这不是我想要的吗?

So what is mod_wsgi-httpd? And is it certain this isn't the one I want?

最后,谁能提供一个从源代码安装 mod_wsgi 的链接?

Finally, can anyone provide a link to installing mod_wsgi from source?

我不明白为什么工程师使用 pip install mod_wsgi 而不是 pip3 ....肯定不可能吧?但是如果我确实使用 pip3,我会得到:

I don't get why the engineer is using pip install mod_wsgi rather than pip3 .... Surely that can't be right? But if I do use pip3, I get:

pi@PiDroplet:~$ cd web/piFlask

pi@PiDroplet:~/web/piFlask$ source ./venv3/bin/activate
(venv3)
pi@PiDroplet:~/web/piFlask$ pip3 install mod_wsgi
Downloading/unpacking mod-wsgi
  Downloading mod_wsgi-4.4.12.tar.gz (991kB): 991kB downloaded
  Running setup.py (path:/home/pi/web/piFlask/venv3/build/mod-wsgi/setup.py) egg_info for package mod-wsgi
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/home/pi/web/piFlask/venv3/build/mod-wsgi/setup.py", line 141, in <module>
        'missing Apache httpd server packages.' % APXS)
    RuntimeError: The 'apxs' command appears not to be installed or is not executable. Please check the list of prerequisites in the documentation for this package and install any missing Apache httpd server packages.
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/home/pi/web/piFlask/venv3/build/mod-wsgi/setup.py", line 141, in <module>

    'missing Apache httpd server packages.' % APXS)

RuntimeError: The 'apxs' command appears not to be installed or is not executable. Please check the list of prerequisites in the documentation for this package and install any missing Apache httpd server packages.

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /home/pi/web/piFlask/venv3/build/mod-wsgi
Storing debug log for failure in /home/pi/.pip/pip.log

现在我试试pip3 install mod_wsgi-httpd,编译大概需要五分钟:

And now I try pip3 install mod_wsgi-httpd, it takes about five minutes to compile:

(venv3)
pi@PiDroplet:~/web/piFlask$ pip3 install mod_wsgi-httpd
Downloading/unpacking mod-wsgi-httpd
  Downloading mod_wsgi-httpd-2.4.12.5.tar.gz
  Running setup.py (path:/home/pi/web/piFlask/venv3/build/mod-wsgi-httpd/setup.py) egg_info for package mod-wsgi-httpd
    apr-1.5.2/
    apr-1.5.2/config.layout
    apr-1.5.2/build.conf
    apr-1.5.2/emacs-mode
    :

所以现在我担心我的 Py3 virtualenv 中有第二个 Apache.

So now I'm worried I've got a second Apache sitting in my Py3 virtualenv.

然而,这确实消除了错误;pip3 install mod_wsgi 现在成功完成.

However that does get rid of the error; pip3 install mod_wsgi now completes successfully.

但现在我完全无法按照他的指示去做:我没有 /etc/apache2/mods-available/wsgi_express.load,如果他建议制作它,然后首先这似乎是任意的,其次他建议放入的文本,即 LoadModule wsgi_module/usr/lib/apache2/modules/mod_wsgi-py34.cpython-34m.so --这个文件在我的系统上不存在.

but now I have come completely unstuck trying to follow his instructions: I don't have a /etc/apache2/mods-available/wsgi_express.load, and if he is suggesting making it, then for a start this seems arbitrary, and secondly the text he suggests putting in it, i.e. LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi-py34.cpython-34m.so -- this file doesn't exist on my system.

我有 /etc/apache2/mods-available/wsgi.load

再次沉迷于技术,有人可以给我一条线吗?

Drowning in technology again, can someone throw me a line?

推荐答案

如果他们已激活 Python 3 虚拟环境并且其 bin 目录在该路径中,那么他们可能只需运行 'pip' 而不是 'pip3'.您应该运行which pip"来验证它是否来自您期望的虚拟环境.

If they had activated the Python 3 virtual environment and its bin directory was in there path, then likely they could simply run 'pip' rather than 'pip3'. You should run 'which pip' to verify whether it was coming from the virtual environment you expect.

'mod_wsgi-httpd' 包专门用于安装 Apache 本身的独特实例,以解决系统范围的 Apache 过时或缺少开发头文件的问题,或者无法修改系统范围的配置.当您没有 root 访问权限来修复系统范围的问题并且只对在非特权端口上运行感兴趣因此不需要 root 访问权限时,它通常更相关.您还必须使用mod_wsgi"包中的mod_wsgi-express",该包是在mod_wsgi-httpd"安装后安装的pip",因为这是使用mod_wsgi-httpd"安装版本的Apache的唯一方法.

The 'mod_wsgi-httpd' package is specifically for installing a distinct instance of Apache itself to get around issues where the system wide Apache is out of date or missing development header files, or otherwise can't modify the system wide configuration. It is generally of more relevance when you don't have root access to fix system wide issues and are only interested in running on an unprivileged port and so do not need root access. You would also have to be using 'mod_wsgi-express' from the 'mod_wsgi' package which was 'pip' installed after 'mod_wsgi-httpd' had been installed as that is the only way to use 'mod_wsgi-httpd' installed version of Apache.

因此,对于mod_wsgi-httpd",您真的很想忽略它.如果您已经安装了它,那么pip"将同时卸载它和mod_wsgi".后者需要卸载,因为它将绑定到 'mod_wsgi-httpd' Apache 版本,而 'mod_wsgi.so' 将无法在系统范围内工作.

So, for 'mod_wsgi-httpd' you would really want to ignore it. If you have already installed it, then 'pip' uninstall both it and 'mod_wsgi'. The latter needs to be uninstalled as it will be bound to the 'mod_wsgi-httpd' Apache version and the 'mod_wsgi.so' will not work with the system wide.

至于在链接中分离用户步骤,它们看起来是正确的,虽然我会说在第 3 步中,应该强调 LoadModuleWSGIPythonHome 行添加的是运行 mod_wsgi-express install-module 命令时的输出.输出什么是定制的以匹配您的安装应该是什么.所以不要编造值,只需使用该命令输出的内容即可.

As to separate users steps in link, they look correct, although I would say that in step 3, it should be highlighted that the LoadModule and WSGIPythonHome lines to be added are what is output when running mod_wsgi-express install-module command. What are output is customised to match what your installation should be. So don't make up values, just use what that command output.

如果您仍有 wsgi.load 文件,请运行 sudo a2dismod wsgi 以删除它或以其他方式手动删除它.它是旧系统打包的 mod_wsgi 遗留下来的.

If you have a wsgi.load file still around, run sudo a2dismod wsgi to get rid of it or otherwise manually remove it. It is a left over from old system packaged mod_wsgi.

这篇关于在 Ubuntu 上为 Python3 安装 mod_wsgi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆