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

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

问题描述

任何人都可以给我清晰的指令集,以便在Ubuntu 3上的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的日志并意识到我已经遇到了这个问题:

...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".您应该运行哪个小知识"来验证它是否来自您期望的虚拟环境.

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',因为这是使用Apache'mod_wsgi-httpd'安装版本的唯一方法

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".后者需要卸载,因为它将绑定到Apache的"mod_wsgi-httpd"版本,而"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天全站免登陆