简体   繁体   English

在 Redhat 7 上为 python3 配置 mod_wsgi

[英]Configuring mod_wsgi for python3 on Redhat 7

I am trying to configure an Apache Server to host my Flask API's using WSGI and Apache.我正在尝试使用 WSGI 和 Apache 配置 Apache 服务器来托管我的 Flask API。

I have installed Apache 2.4.6 on Redhat 7, but the default python version for mod_wsgi is python 2.7.我已经在 Redhat 7 上安装了 Apache 2.4.6,但是 mod_wsgi 的默认 python 版本是 python 2.7。

I have been following this guide: https://curiousdba.netlify.app/post/djangoonrhel7/我一直在关注本指南: https://curiousdba.netlify.app/post/djangoonrhel7/

I installed mod_wsgi module for python3 using:我使用以下命令为 python3 安装了 mod_wsgi 模块:

pip3 install mod_wsgi

But I encounter an error when using:但是我在使用时遇到错误:

mod_wsgi-express install-module> /etc/httpd/conf.modules.d/02-wsgi.conf

bash: mod_wsgi-express : command not found..

Any idea how I can work on this.知道我该如何解决这个问题。

I have also tried installing rh-python36-mod_wsgi using yum package manager but it couldn't find any such package.我也尝试使用 yum package 管理器安装rh-python36-mod_wsgi ,但它找不到任何这样的 package。

If you are using Linux, macOS or other UNIX type operating system, and you don't have Apache available, you can instead install mod_wsgi using:如果您使用的是 Linux、macOS 或其他 UNIX 类型的操作系统,并且您没有 Apache 可用,则可以使用以下方式安装 mod_wsgi:

pip install mod_wsgi-standalone

When installing mod_wsgi-standalone , it will also install a version of Apache into your Python distribution.安装mod_wsgi-standalone时,它还会将 Apache 版本安装到您的 Python 发行版中。 You can only use mod_wsgi-express when using this variant of the package.在使用 package 的此变体时,您只能使用mod_wsgi-express The mod_wsgi-standalone package follows the same version numbering as the mod_wsgi package on PyPi. mod_wsgi-standalone package 遵循与 PyPi 上的 mod_wsgi package 相同的版本编号。

You can only use mod_wsgi-express when using this variant of the package .在使用 package 的此变体时,您只能使用 mod_wsgi-express

On a UNIX type system, to verify that the installation was successful, run the mod_wsgi-express script with the start-server command:在 UNIX 类型的系统上,要验证安装是否成功,请使用 start-server 命令运行mod_wsgi-express脚本:

mod_wsgi-express start-server

This will start up Apache/mod_wsgi on port 8000. You can then verify that the installation worked by pointing your browser at:这将在端口 8000 上启动 Apache/mod_wsgi。然后您可以通过将浏览器指向以下位置来验证安装是否有效:

http://localhost:8000/

When started in this way, the Apache web server will stay in the foreground.以这种方式启动时,Apache web 服务器将停留在前台。 To stop the Apache server, use CTRL-C.要停止 Apache 服务器,请使用 CTRL-C。

https://pypi.org/project/mod-wsgi/ https://pypi.org/project/mod-wsgi/

try this one for python 3.6:试试这个 python 3.6:

yum install python36u-mod_wsgi百胜安装 python36u-mod_wsgi

and for python 3.8:对于 python 3.8:

yum install python38-mod_wsgi百胜安装 python38-mod_wsgi

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM