在apaches上部署Django应用程序

2024-09-29 23:31:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在apache服务器(Xampp)上部署django应用程序

现有版本:

Python 3.7.3
Xampp :- 3.2.4
Apache :- 2.4
windows 10

在注:-i使用虚拟环境

正在搜索如何执行此操作,并遇到此Tutorial

但是,在进行了与django文档相同的更改之后。我的apache服务器没有运行

它抛出了错误

Error: Apache shutdown unexpectedly. This may be due to a blocked port, missing dependencies, improper privileges, a crash, or a shutdown by another method. Press the Logs button to view error logs and check the Windows Event Viewer for more clues If you need more help, copy and post this entire log window on the forums

我确实在httpd.conf对于另一个应用程序未使用的其他文件,我无法确定问题所在。在

添加到httpd.conf在

^{pr2}$

也在httpd确认如果我在注释添加的行,那么apache可以正常工作,但是当我取消注释这些行时,apache就不能工作了。:-(

感谢那些愿意帮忙的人。:-)

Windows事件查看器日志:-

[Sat Aug 10 19:00:05.852622 2019] [ssl:warn] [pid 9612:tid 560] AH01909: www.example.com:4433:0 server certificate does NOT include an ID which matches the server name
[Sat Aug 10 19:00:05.928109 2019] [core:warn] [pid 9612:tid 560] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Sat Aug 10 19:00:06.027802 2019] [ssl:warn] [pid 9612:tid 560] AH01909: www.example.com:4433:0 server certificate does NOT include an ID which matches the server name
[Sat Aug 10 19:00:06.049409 2019] [mpm_winnt:notice] [pid 9612:tid 560] AH00455: Apache/2.4.39 (Win64) OpenSSL/1.0.2s PHP/7.1.30 configured -- resuming normal operations
[Sat Aug 10 19:00:06.049409 2019] [mpm_winnt:notice] [pid 9612:tid 560] AH00456: Apache Lounge VC14 Server built: May 29 2019 14:38:49
[Sat Aug 10 19:00:06.049409 2019] [core:notice] [pid 9612:tid 560] AH00094: Command line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Sat Aug 10 19:00:06.072102 2019] [mpm_winnt:notice] [pid 9612:tid 560] AH00418: Parent: Created child process 12636
[Sat Aug 10 19:00:06.769853 2019] [ssl:warn] [pid 12636:tid 524] AH01909: www.example.com:4433:0 server certificate does NOT include an ID which matches the server name
[Sat Aug 10 19:00:06.959523 2019] [ssl:warn] [pid 12636:tid 524] AH01909: www.example.com:4433:0 server certificate does NOT include an ID which matches the server name
[Sat Aug 10 19:00:06.981305 2019] [mpm_winnt:notice] [pid 12636:tid 524] AH00354: Child: Starting 150 worker threads.

Tags: thesslserverexampleapachewwwpidsat
2条回答

这里https://github.com/GrahamDumpleton/mod_wsgi/blob/develop/win32/README.rst有4个要求你应该遵守。在

据我所知,您没有遵守第一条规则,因为您有apachewin64版本Apache/2.4.39 (Win64),但是您使用的是32位python版本和mod_gwsgipython37-32/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win32.pyd

另外,我注意到你说你在使用虚拟环境。请确保您的wsgi.py首先加载虚拟环境。我的文件是这样开始的:

python_home='/path/to/the/djangoproject/venv'
activate_this=python_home+'/bin/activate_this.py'
with open(activate_this) as file_:
        exec(file_.read(), dict(__file__=activate_this))

另外,我建议通过在VirtualHost文件中指定WSGIDaemonProcess和WSGIProcessGroup指令,将mod帴wsgi配置为在守护程序模式下运行。在

在日志中(在配置的步骤中),它也应该显示WSGI模块的版本。 但是你的日志没有提到任何关于WSGI的信息,所以我怀疑你没有正确地进行WSGI设置。 我发布了一个来自apache的示例日志(当然它是不同的操作系统,但应该是相似的)。在

[Fri Aug 02 13:51:39.962856 2019] AH00163: Apache/2.4.39 (Unix) mod_wsgi/4.6.7 Python/3.7 configured   resuming normal operations

相关问题 更多 >

    热门问题