gpt4 book ai didi

python - Apache 如何使用 Py3 而不是 Py2?

转载 作者:太空宇宙 更新时间:2023-11-04 05:26:28 24 4
gpt4 key购买 nike

Apache 如何使用 Python/3.x 而不是 Python/2.x?

我现在正在尝试使用 Py3 在服务器上设置 Django 应用程序。命令 python manage.py runserver 成功。然后我尝试使用 Apachemod_wsgi 但我遇到了 Internal Server Error

错误日志说

[mpm_prefork:notice] [pid 30732] AH00163: Apache/2.4.6 (CentOS) mod_wsgi/3.4 Python/2.7.5 configured -- resuming normal operations

但默认的 python 是 Py3。

# python -V
Python 3.5.1

我想知道当 apache 使用 Py3 时错误会被修复。你呢?如何指定 Py3?

开始命令

# /etc/init.d/httpd restart

完整的错误日志

$ tailf  /etc/httpd/logs/error_log
[Thu Jul 21 15:32:20.626731 2016] [auth_digest:notice] [pid 30732] AH01757: generating secret for digest authentication ...
[Thu Jul 21 15:32:20.627378 2016] [lbmethod_heartbeat:notice] [pid 30732] AH02282: No slotmem from mod_heartmonitor
[Thu Jul 21 15:32:20.629557 2016] [mpm_prefork:notice] [pid 30732] AH00163: Apache/2.4.6 (CentOS) mod_wsgi/3.4 Python/2.7.5 configured -- resuming normal operations
[Thu Jul 21 15:32:20.629580 2016] [core:notice] [pid 30732] AH00094: Command line: '/usr/sbin/httpd'
[Thu Jul 21 15:37:31.940196 2016] [mpm_prefork:notice] [pid 30732] AH00169: caught SIGTERM, shutting down
[Thu Jul 21 15:37:31.981414 2016] [suexec:notice] [pid 30777] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Thu Jul 21 15:37:31.993034 2016] [auth_digest:notice] [pid 30778] AH01757: generating secret for digest authentication ...
[Thu Jul 21 15:37:31.993935 2016] [lbmethod_heartbeat:notice] [pid 30778] AH02282: No slotmem from mod_heartmonitor
[Thu Jul 21 15:37:31.996832 2016] [mpm_prefork:notice] [pid 30778] AH00163: Apache/2.4.6 (CentOS) mod_wsgi/3.4 Python/2.7.5 configured -- resuming normal operations
[Thu Jul 21 15:37:31.996866 2016] [core:notice] [pid 30778] AH00094: Command line: '/usr/sbin/httpd'

环境

Apache/2.4.6 (CentOS) 
mod_wsgi/3.4
Python 3.5.1
Django 1.9
CentOS 7.1

最佳答案

如果您正在使用已编译的 mod_wsgi,您需要针对您要使用的版本针对适当的 Python 二进制文件对其进行编译,否则它将默认为系统 Python 版本(通常仍为 2 .x,不幸的是)。例如:

wget -q "https://github.com/GrahamDumpleton/mod_wsgi/archive/4.4.21.tar.gz"
tar -xzf '4.4.21.tar.gz'
cd ./mod_wsgi-4.4.21
./configure --with-python=/usr/local/bin/python3.5
make
make install

祝你好运!

关于python - Apache 如何使用 Py3 而不是 Py2?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38499444/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com