【问题标题】:Check Python Version Used in Mod_WSGI检查 Mod_WSGI 中使用的 Python 版本
【发布时间】:2023-03-07 08:33:02
【问题描述】:

我无法找出 Apache 中的 mod_wsgi 正在使用哪个 python 环境或安装位置。在我的 apache 配置中,我没有提供任何特定的 venv 配置。

        ServerName 
        ServerAlias 
        DocumentRoot /home/Downloads

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        Alias /static /home/Downloads/static
        <Directory /home/Downloads/static>
                Require all granted
        </Directory>

        <Directory /home/Downloads/samples>
                Require all granted
        </Directory>

        <Directory /home/Downloads>
                <Files wsgi.py>
                        Require all granted
                </Files>
        </Directory>

        #WSGIDaemonProcess group python-path=/home/Downloads python-home=/home/envlin
        WSGIProcessGroup group
        WSGIScriptAlias / /home/Downloads/wsgi.py

我删除了关键信息并替换为随机信息。

这是我的 apache 重启日志

Apache 日志

Apache/2.4.46 (Ubuntu) OpenSSL/1.1.1j mod_wsgi/4.7.1 Python/3.9 configured -- resuming normal operations

问题

有什么方法可以获取 mod_wsgi 正在使用哪个 python 版本和安装位置。

**Python 路径的** 如果我获取 python 路径通常是这里的结果。

sys.path = [
    '/root',
    '/usr/lib/python39.zip',
    '/usr/lib/python3.9',
    '/usr/lib/python3.9/lib-dynload',
    '/usr/local/lib/python3.9/dist-packages',
    '/usr/lib/python3/dist-packages',
    '/usr/lib/python3.9/dist-packages',
]

【问题讨论】:

  • 您实际上发布了该信息,不是吗?
  • 但是在这些 dist-packages 中,我找不到我从 requirements.txt 安装的 pip 安装包。只是想确认一下我是否可以得到正在使用的python mod_wsgi或python版本的路径。
  • 你是如何安装这些包的? virtualenv 是否处于活动状态?
  • pip install -r requirements.txt

标签: python django apache web mod-wsgi


【解决方案1】:

我没有找到直接获取mod_wsgi版本的方法,但是我以root用户进入根目录并运行了一个find命令。

/home//Downloads/env/lib/python3.9/site-packages/allauth
/home//gmcwebenvlin/lib/python3.9/site-packages/allauth
/home//.local/lib/python3.9/site-packages/allauth

并尝试在所有包中更改 urls.py 中的变量并在一个包中工作。

事实证明,即使我们在 Apache 中为网站的 SSL version 指定不同的配置文件,Python 主页仍然是从 non-SSL version 配置中提取的。

【讨论】:

    猜你喜欢
    • 2017-01-28
    • 2017-10-13
    • 1970-01-01
    • 1970-01-01
    • 2016-04-10
    • 2012-04-21
    • 2020-12-03
    • 2018-08-27
    • 2018-09-24
    相关资源
    最近更新 更多