【问题标题】:Why doesn't mod_wsgi support daemon mode on Windows?为什么 mod_wsgi 在 Windows 上不支持守护程序模式?
【发布时间】:2023-12-30 01:40:01
【问题描述】:

http://code.google.com/p/modwsgi/ 上可以阅读此声明

mod_wsgi 的守护程序模式将 仅在 Apache 2.0 或 2.2 上可用 在 UNIX 上运行,并且仅当 Apache 运行时库底层 Apache 已在支持下编译 用于线程。

Windows下不支持daemon模式的原因是什么?

得到后发现上面的

Invalid command 'WSGIDaemonProcess', perhaps misspelled or defined by a module not included in the server configuration

来自 Apache 的错误。包含模块不是问题,因为WSGIScriptAlias 指令可以正常工作。我猜我得到的错误是由于 mod_wsgi 的 wiki 上描述的限制。

【问题讨论】:

    标签: python windows apache mod-wsgi


    【解决方案1】:

    Windows 不提供 UNIX 风格的 fork() 系统调用,因此子进程继承父进程内存映像的进程生成是不可能的。 Apache/mod_wsgi 需要 fork()。

    【讨论】:

    • 我猜 Apache 使用 Apache Portable Runtime 库,它看起来是处理某些操作系统中缺少 fork() 的理想场所。 APR 被建议作为 Windows here 上缺少 fork() 的解决方案。但是我查看了 APR 的文档,它看起来像 does not 在 Windows 上实现 fork()。
    【解决方案2】:

    对于所有在阅读 Graham 的回答后想了解更多关于 Windows 上的 fork() 的人,这里有与此主题相关的问题:

    What is the closest thing windows has to fork()?
    substitute for fork()ing? in windows.
    CreateThread vs fork()
    fork/chroot equivalent for Windows server application
    Where does Microsoft Windows 7 POSIX implementation currently stands?

    上面线程中提到的两个有趣的事情是:

    另外我问Does Interix implement fork()?

    【讨论】: