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

uzl*_*zla 5 apache mod-wsgi centos python-3.x

标题是"如何在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
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

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

car*_*rge 8

我看到你已经启用了IUS repo.您可以只安装普通的软件包,而不是跳过SCL篮球.

yum install python35u-mod_wsgi
Run Code Online (Sandbox Code Playgroud)

这将使用标准文件系统位置来处理Apache HTTPD 2.4的库存.

/etc/httpd/conf.modules.d/10-wsgi-python3.5.conf
/usr/lib64/httpd/modules/mod_wsgi_python3.5.so
Run Code Online (Sandbox Code Playgroud)


Don*_*kby 6

我尝试遵循卡尔的回答,但是并不能解决问题。事实证明,我安装的版本在安装后需要一些额外的配置步骤。

背景

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

$ ls -l /lib64/httpd/modules
[...]
-rwxr-xr-x. 1 root root 172800 Oct 30 22:44 mod_wsgi.so
Run Code Online (Sandbox Code Playgroud)

然后,我安装了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
[...]
Run Code Online (Sandbox Code Playgroud)

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

$ sudo yum install -q -y rh-python36-mod_wsgi
[...]
$ sudo systemctl restart httpd
Run Code Online (Sandbox Code Playgroud)

可悲的是,那并不能解决问题。当我查看Apache的modules文件夹时,没有任何变化。奇怪的!

$ ls -l /lib64/httpd/modules
[...]
-rwxr-xr-x. 1 root root 172800 Oct 30 22:44 mod_wsgi.so
Run Code Online (Sandbox Code Playgroud)

那么安装了什么呢?

$ 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
Run Code Online (Sandbox Code Playgroud)

额外的配置步骤

它安装了我需要的文件,但没有将它们放在有用的地方。有了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
Run Code Online (Sandbox Code Playgroud)

现在,我具有的正确版本mod_wsgi,并且我的Django应用将在Apache下运行。