如何在 CentOS 7 上使用 python3.5 为 apache 2.4 安装 mod_wgsi

新手上路,请多包涵

正如标题所说“如何在 CentOS 7 上为 python3.5 安装 mod_wgsi”?

$pip3.5 安装 mod_wgsi 没有工作

Collecting mod_wgsi
  Could not find a version that satisfies the requirement mod_wgsi (from versions: )
No matching distribution found for mod_wgsi

sudo yum install libapache2-mod-wsgi-py3 也失败了:

 Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with Subscription Management. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
 * base: mirror.daniel-jost.net
 * epel: mirrors.n-ix.net
 * extras: mirror.daniel-jost.net
 * ius: mirror.amsiohosting.net
 * remi: mirror.23media.de
 * remi-php56: mirror.23media.de
 * remi-safe: mirror.23media.de
 * updates: mirror.daniel-jost.net
No package libapache2-mod-wsgi-py3 available.
Error: Nothing to do

非常欢迎任何关于如何在 CentOS 7 上使用 python3.5 运行 apache2.4+ mod_wsgi 的建议!

原文由 uzla 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 846
2 个回答

我看到您已经启用了 IUS 存储库。您无需跳过 SCL 环,只需安装一个普通包即可。

 yum install python35u-mod_wsgi

这将使用标准文件系统位置来处理现有的 Apache HTTPD 2.4。

 /etc/httpd/conf.modules.d/10-wsgi-python3.5.conf
/usr/lib64/httpd/modules/mod_wsgi_python3.5.so

原文由 carlwgeorge 发布,翻译遵循 CC BY-SA 3.0 许可协议

我尝试按照 Carl 的回答 进行操作,但并没有解决问题。原来我安装的版本安装后需要一些额外的配置步骤。

背景

在安装 mod_wsgi 升级之前,我查看了 Apache 的 modules 文件夹:

 $ ls -l /lib64/httpd/modules
[...]
-rwxr-xr-x. 1 root root 172800 Oct 30 22:44 mod_wsgi.so

然后我安装了 SCL 存储库,并查看了 mod_wsgi 的哪些版本可用。

 $ sudo yum install -q -y centos-release-scl
[...]
$ yum search mod_wsgi
[...]
koschei-frontend.noarch : Web frontend for koschei using mod_wsgi
mod_wsgi.x86_64 : A WSGI interface for Python web applications in Apache
python27-mod_wsgi.x86_64 : A WSGI interface for Python web applications in Apache
python33-mod_wsgi.x86_64 : A WSGI interface for Python web applications in Apache
rh-python34-mod_wsgi.x86_64 : A WSGI interface for Python web applications in Apache
rh-python35-mod_wsgi.x86_64 : A WSGI interface for Python web applications in Apache
rh-python36-mod_wsgi.x86_64 : A WSGI interface for Python web applications in Apache
viewvc-httpd-wsgi.noarch : ViewVC configuration for Apache/mod_wsgi
[...]

我使用的是 Python 3.6,所以我安装了匹配的版本并重新启动了 Apache。

 $ sudo yum install -q -y rh-python36-mod_wsgi
[...]
$ sudo systemctl restart httpd

可悲的是,这并没有解决问题。当我查看 Apache 的 modules 文件夹时,没有任何变化。诡异的!

 $ ls -l /lib64/httpd/modules
[...]
-rwxr-xr-x. 1 root root 172800 Oct 30 22:44 mod_wsgi.so

那么安装了什么?

 $ rpm -ql rh-python36-mod_wsgi
/opt/rh/httpd24/root/etc/httpd/conf.modules.d/10-rh-python36-wsgi.conf
/opt/rh/httpd24/root/usr/lib64/httpd/modules/mod_rh-python36-wsgi.so
/opt/rh/rh-python36/root/usr/share/doc/rh-python36-mod_wsgi-4.5.18
/opt/rh/rh-python36/root/usr/share/doc/rh-python36-mod_wsgi-4.5.18/CREDITS.rst
/opt/rh/rh-python36/root/usr/share/doc/rh-python36-mod_wsgi-4.5.18/LICENSE
/opt/rh/rh-python36/root/usr/share/doc/rh-python36-mod_wsgi-4.5.18/README.rst

额外的配置步骤

它安装了我需要的文件,但没有把它们放在任何有用的地方。根据 README.rst 文件的一些提示,我将它们复制到正确的位置。

 sudo cp /opt/rh/httpd24/root/usr/lib64/httpd/modules/mod_rh-python36-wsgi.so /lib64/httpd/modules
sudo cp /opt/rh/httpd24/root/etc/httpd/conf.modules.d/10-rh-python36-wsgi.conf /etc/httpd/conf.modules.d
sudo systemctl restart httpd

现在我有了正确版本的 mod_wsgi ,我的 Django 应用程序将在 Apache 下运行。

原文由 Don Kirkby 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进