【发布时间】:2020-06-09 18:33:22
【问题描述】:
我正在通过 Apache 将一个新的 Django 项目部署到本地 Windows 服务器,其中包含两个预先存在的 Django 项目。该站点在服务器上本地运行时可以工作,但不能通过 WSGI 运行。我正在使用 mailmerge 包来操作一些 docx 模板,当网站加载时,它在“来自 lxml.etree 导入元素”这一行上失败。
我已经尝试修改mailmerge.py文件中的导入命令无济于事。我已经在我的 virtualenv 内外安装了 lxml 和 mailmerge 包。我已经用谷歌搜索过这个网站和其他网站,但是当我尝试各种修复操作时,搜索结果要么不适用,要么没有解决问题。
这是我的项目 Apache 错误日志中的 sn-p:
这是我的 wsgi_windows.py 文件:
# execfile(activate_this, dict(__file__=activate_this))
exec(open(activate_this).read(),dict(__file__=activate_this))
import os
import sys
import site
# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('D:/QR/qr_env/Lib/site-packages')
# Add the app's directory to the PYTHONPATH
sys.path.insert(0,'D:/QR')
sys.path.insert(1,'D:/QR/quality_review')
os.environ['DJANGO_SETTINGS_MODULE'] = 'quality_review.settings'
#os.environ.setdefault("DJANGO_SETTINGS_MODULE", "quality_review.settings")
os.environ["DJANGO_SETTINGS_MODULE"] = "quality_review.settings"
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application
这是项目在 vhosts.conf 文件中的条目:
<VirtualHost *:8082>
ServerName **********
WSGIPassAuthorization On
ErrorLog "logs/quality_review.error.log"
CustomLog "logs/quality_review.access.log" combined
WSGIScriptAlias / "D:\QR\quality_review\wsgi_windows.py"
<Directory "D:\QR\quality_review">
<Files wsgi_windows.py>
Require all granted
</Files>
</Directory>
Alias /static "D:\QR\static"
<Directory "D:\QR\static">
Require all granted
</Directory>
Alias /documents "D:\QR\documents"
<Directory "D:\QR\documents">
Require all granted
</Directory>
</VirtualHost>
httpd.conf:
LoadFile "c:/users/rcs/appdata/local/programs/python/python37-32/python37.dll"
LoadModule wsgi_module "c:/users/rcs/appdata/local/programs/python/python37-32/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win32.pyd"
WSGIPythonHome "c:/users/rcs/appdata/local/programs/python/python37-32"
这是来自主要 Apache 错误日志的最新 sn-p:
[Wed Jun 10 12:00:56.550356 2020] [mpm_winnt:notice] [pid 480:tid 560] AH00418: Parent: Created child process 5412
[Wed Jun 10 12:00:56.550356 2020] [mpm_winnt:debug] [pid 480:tid 560] mpm_winnt.c(430): AH00402: Parent: Sent the scoreboard to the child
[Wed Jun 10 12:00:56.878480 2020] [mpm_winnt:debug] [pid 5412:tid 460] mpm_winnt.c(1719): AH00453: Child process is running
[Wed Jun 10 12:00:56.878480 2020] [wsgi:info] [pid 5412:tid 460] mod_wsgi (pid=5412): Python home c:/users/rcs/appdata/local/programs/python/python37.
[Wed Jun 10 12:00:56.878480 2020] [wsgi:info] [pid 5412:tid 460] mod_wsgi (pid=5412): Initializing Python.
[Wed Jun 10 12:00:56.894105 2020] [wsgi:info] [pid 5412:tid 460] mod_wsgi (pid=5412): Attach interpreter ''.
[Wed Jun 10 12:00:56.909730 2020] [wsgi:info] [pid 5412:tid 460] mod_wsgi (pid=5412): Imported 'mod_wsgi'.
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 5412:tid 460] mpm_winnt.c(344): AH00391: Child: Retrieved our scoreboard from the parent.
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 480:tid 560] mpm_winnt.c(513): AH00408: Parent: Duplicating socket 424 (0.0.0.0:8082) and sending it to child process 5412
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 5412:tid 460] mpm_winnt.c(466): AH00403: Child: Waiting for data for listening socket 0.0.0.0:8082
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 480:tid 560] mpm_winnt.c(513): AH00408: Parent: Duplicating socket 420 ([::]:8082) and sending it to child process 5412
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 480:tid 560] mpm_winnt.c(513): AH00408: Parent: Duplicating socket 416 (0.0.0.0:8081) and sending it to child process 5412
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 480:tid 560] mpm_winnt.c(513): AH00408: Parent: Duplicating socket 412 ([::]:8081) and sending it to child process 5412
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 480:tid 560] mpm_winnt.c(513): AH00408: Parent: Duplicating socket 400 (0.0.0.0:8080) and sending it to child process 5412
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 480:tid 560] mpm_winnt.c(513): AH00408: Parent: Duplicating socket 408 ([::]:8080) and sending it to child process 5412
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 480:tid 560] mpm_winnt.c(532): AH00411: Parent: Sent 6 listeners to child 5412
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 5412:tid 460] mpm_winnt.c(466): AH00403: Child: Waiting for data for listening socket [::]:8082
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 5412:tid 460] mpm_winnt.c(466): AH00403: Child: Waiting for data for listening socket 0.0.0.0:8081
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 5412:tid 460] mpm_winnt.c(466): AH00403: Child: Waiting for data for listening socket [::]:8081
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 5412:tid 460] mpm_winnt.c(466): AH00403: Child: Waiting for data for listening socket 0.0.0.0:8080
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 5412:tid 460] mpm_winnt.c(466): AH00403: Child: Waiting for data for listening socket [::]:8080
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 5412:tid 460] mpm_winnt.c(491): AH00407: Child: retrieved 6 listeners from parent
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 5412:tid 460] child.c(969): AH00352: Child: Acquired the start mutex.
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:notice] [pid 5412:tid 460] AH00354: Child: Starting 64 worker threads.
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 5412:tid 1172] child.c(430): AH00334: Child: Accept thread listening on 0.0.0.0:8082 using AcceptFilter connect
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 5412:tid 1180] child.c(430): AH00334: Child: Accept thread listening on 0.0.0.0:8080 using AcceptFilter connect
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 5412:tid 1192] child.c(430): AH00334: Child: Accept thread listening on [::]:8080 using AcceptFilter connect
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 5412:tid 1208] child.c(430): AH00334: Child: Accept thread listening on [::]:8081 using AcceptFilter connect
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 5412:tid 1204] child.c(430): AH00334: Child: Accept thread listening on 0.0.0.0:8081 using AcceptFilter connect
[Wed Jun 10 12:00:56.909730 2020] [mpm_winnt:debug] [pid 5412:tid 1212] child.c(430): AH00334: Child: Accept thread listening on [::]:8082 using AcceptFilter connect
我不确定还需要哪些其他信息来提供帮助,但如果需要,我很乐意提供其他文件。
【问题讨论】:
-
请分享您的 apache.conf LoadFile "***ython37.dll" 和 LoadModule wsgi_module "***\mod_wsgi.cp37-win_amd64.pyd" 中的相似行
-
我已使用请求的信息编辑了我的帖子。感谢您的回复。
-
你的windows系统是32位的?
-
不,它是 64 位 Windows。
-
你已经安装了32位版本的python37:/mod_wsgi.cp37-win32.pyd"
标签: python django apache mod-wsgi