有谁能给我一套关于在Ubuntu for Python 3上安装mod_wsgi的清晰说明吗?

我确实得到了Flask&mod_wsgi成功地使用了Python3,并在一瞬间感到高兴.

...直到我看了Apache的日志(log),意识到我遇到了这个问题: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日志(log)中出现错误.(Should I report this and if so where?)

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

有趣的是,他似乎正在把它安装到一个虚拟的Python3环境中.(这与使用system pip3有什么不同吗?)

他还使用pip3 install mod_wsgi,但返回pip3 search mod_wsgi:

(EDIT: no he doesn't, he uses pip not pip3. Can that be right? Has he got his wires crossed? Isn't pip going to ignore the fact that he is in his py3venv and simply use the system's py2 installation? But anyway that doesn't resolve the confusion...)

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是多少?这肯定不是我想要的吗?

最后,有人能提供从源代码安装mod_wsgi的链接吗?

编辑:我不明白为什么工程师用pip install mod_wsgi而不是pip3 ....这肯定不对吧?但如果我使用pip3,我会得到:

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次,编译大约需要5分钟:

(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.

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

编辑:但现在我完全没有按照他的指示go 做:我没有/etc/apache2/mods-available/wsgi_express.load,如果他建议做,那么首先这似乎是武断的,其次是他建议放入的文本,即LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi-py34.cpython-34m.so——这个文件在我的系统中不存在.

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

又一次沉溺于科技,有人能给我一句台词吗?

推荐答案

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

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

所以,对于"mod_wsgi-httpd",你真的想忽略它.如果您已经安装了它,那么"pip"将同时卸载它和"mod_wsgi".后者需要卸载,因为它将绑定到"mod_wsgi-httpd"Apache版本和"mod_wsgi".所以"不适用于整个系统".

至于链接中的单独用户步骤,它们看起来是正确的,尽管我想说,在步骤3中,应该强调的是,要添加的LoadModule行和WSGIPythonHome行是运行mod_wsgi-express install-module命令时输出的内容.输出是定制的,以匹配您的安装.所以,不要构造值,只使用命令输出的内容.

如果还有wsgi.load个文件,请运行sudo a2dismod wsgi将其删除,或者手动将其删除.它是旧系统打包mod_wsgi的遗留产品.

Python-3.x相关问答推荐

从.csv导入将文件夹路径加入到文件名

匹配语句NaN

对大型数据框中的选定列进行重新排序

命名空间前缀无效

Python webdrivermanager 和 Chrome 115.0 的 URL https://chromedriver.storage.googleapis.com/LATEST_RELEASE_115.0.5790 错误没有此类驱动程序

为什么 get_form 方法中小部件的更改没有反映 Django 管理站点中的更改

torch.stack([t1, t1, t1], dim=1)与torch.hstack([t1, t1, t1])之间有什么区别?

如何将多输入数据加载器传递给单输入模型

将水平堆叠的数据排列成垂直

删除给定数组中所有元素为True的所有子数组

如果值超出上下限(异常值处理),则将值的数据框替换为 np.nan

如何将具有多个参数的函数传递给 python concurrent.futures.ProcessPoolExecutor.map()?

基本 Flask 应用程序未运行(TypeError:模块中缺少必填字段type_ignores)

ValueError:FixedLocator 位置的数量 (5),通常来自对 set_ticks 的调用,与刻度标签的数量 (12) 不匹配

使用逗号时,除了处理程序中的语法无效

导入父目录进行简要测试

如何对字典的函数输出列表进行单元测试?

有效地判断一个元素是否在列表中至少出现 n 次

通过字典有效地替换Pandas 系列中的值

TypeError:无法将系列转换为