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

问题描述 投票:4回答:4

标题是“如何在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的任何建议都是非常受欢迎的!

apache python-3.x centos mod-wsgi
4个回答
7
投票

我看到你已经启用了IUS repo。您可以只安装普通的软件包,而不是跳过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

3
投票

我试过跟随Carl's answer,但它没有解决问题。事实证明,我安装的版本在安装后需要一些额外的配置步骤。

Background

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

$ 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 qazxsw poi文件夹时,一切都没有改变。奇怪的!

modules

那么安装了什么?

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

Extra Configuration Steps

它安装了我需要的文件,但没有把它们放在任何有用的地方。通过$ 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 ,我的Django应用程序将在Apache下运行。


1
投票

你检查rh-python35软件集合提供rh-python35-mod_wsgi包吗?

有关SCL的更多信息,请参阅:


0
投票

我会使用RHSCL 2.3 release announcement(虽然可以自由地替换下面的3.5)。

开始:

SCL packages for python 3.6

请注意,将引入SCL包yum install centos-release-scl yum install rh-python36 rh-python36-mod_wsgi 并将mod_wsgi文件放入该安装中。我建议你使用该安装,而不是安装基本的CentOS httpd24-httpd包。在撰写本文时,对于CentOS 7,httpd包为2.4.6,httpd包为2.4.37。

然后你创建一个virtualenv:

httpd24-httpd

现在,您可以将您的站点的配置放在/opt/rh/rh-python36/root/usr/bin/python -m venv /path/to/venv36 source /path/to/venv36/bin/activate pip install ... 中,其中可能包含以下内容:

/opt/rh/httpd24/root/etc/httpd/conf.d/mysite.conf

现在启动SCL apache:

<VirtualHost *:80>
    LoadModule wsgi_module modules/mod_wsgi.so

    ErrorLog /var/log/httpd24/mysite-err.log
    CustomLog  /var/log/httpd24/mysite.log combined

    # recommended way of setting DJANGO_SETTINGS_MODULE http://stackoverflow.com/a/25496668/3189
    WSGIProcessGroup mysite.settings.production
    WSGIDaemonProcess mysite.settings.production python-path=/path/to/mysite/:/path/to/venv36/lib/python3.6/site-packages
    WSGIScriptAlias / /path/to/mysite/wsgi.py process-group=mysite application-group=%{GLOBAL}
</VirtualHost>

并且您的网站应该正常运行。

© www.soinside.com 2019 - 2024. All rights reserved.