【发布时间】:2021-01-21 09:41:27
【问题描述】:
我正在尝试将旧的 Django 应用程序 (1.7) 部署到 Debian 上的 Apache2 服务器。我终于能够使用./manage.py runserver 运行该应用程序,但我没有成功让mod-wsgi 工作。我从来没有用 Python 编写过服务器端应用程序,所以我可能遗漏了一些明显的东西。
这些是我遵循的步骤
- 我尝试的一切都是
/usr/bin/python,即2.7 - 我知道,我应该使用virtuelenv,但我不想给整个事情增加更多的复杂性(因为我不熟悉它) - 安装
mod-wsgi和apt-get install libapache2-mod-wsgi - 将以下配置添加到 /etc/apache2/mods-enabled/wsgi.conf
- Apache2 重启
<IfModule mod_wsgi.c>
WSGIScriptAlias / /home/rosasystem.pl/public_html/rosasystem/rosasystem/wsgi.py
WSGIPythonHome /usr/bin/python
WSGIPythonPath /home/rosasystem.pl/public_html/rosasystem
LogLevel warn
<Directory /home/rosasystem.pl/public_html/rosasystem/rosasystem>
<Files wsgi.py>
Order deny,allow
Require all granted
</Files>
</Directory>
</IfModule>
从那时起,我不断在error.log 中收到此错误消息 - 我在 Google 上搜索的大部分内容表明,mod-wsgi 和 system/virtualenv Python 版本之间存在 Python 版本差异,而这并不存在有道理,因为一切都是 Python 2.7。
[Tue Oct 06 15:13:42.946626 2020] [mpm_event:notice] [pid 17059:tid 139874785088640] AH00489: Apache/2.4.38 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1g mod_wsgi/4.6.5 Python/2.7 configured -- resuming normal operations
[Tue Oct 06 15:13:42.946650 2020] [core:notice] [pid 17059:tid 139874785088640] AH00094: Command line: '/usr/sbin/apache2'
[Tue Oct 06 15:13:42.951277 2020] [wsgi:warn] [pid 17061:tid 139874785088640] mod_wsgi (pid=17061): Python home /usr/bin/python is not a directory. Python interpreter may not be able to be initialized correctly. Verify the supplied path.
[Tue Oct 06 15:13:42.951531 2020] [wsgi:warn] [pid 17062:tid 139874785088640] mod_wsgi (pid=17062): Python home /usr/bin/python is not a directory. Python interpreter may not be able to be initialized correctly. Verify the supplied path.
ImportError: No module named site
在这一点上,我几乎被困住了;我可以尝试哪些新事物?
【问题讨论】:
-
你在使用系统 python 的情况下是否在没有 WSGIPythonHome 的情况下尝试过?
-
@WombatPM 是的,我有,没有 chage
-
您是否尝试将 /usr/lib/python2.7 添加到 WSGIPythonPath 中?运行 pip install -r requirements.txt 时是否有任何错误?
标签: python django linux apache mod-wsgi