【问题标题】:Can't get my Apache to work with mod_wsgi无法让我的 Apache 使用 mod_wsgi
【发布时间】:2016-10-10 07:59:01
【问题描述】:

根据指南,我下载了mod_wsgi-win32-ap22py27-3.3.so,将其重命名为 mod_wsgi.so 并将其放入 Apache 的 /modules 文件夹中。

接下来,我将“LoadModule wsgi_module modules/mod_wsgi.so”行添加到 httpd.conf。

当启动 Apache 时,它​​给我这个错误:“请求的操作失败了!”

这是error.log的输出:

Starting the Apache2.2 service
The Apache2.2 service is running.
] Apache/2.2.25 (Win32) configured -- resuming normal operations
[Fri Oct 07 12:59:37 2016] [notice] Server built: Jul 10 2013 01:52:12
[Fri Oct 07 12:59:37 2016] [notice] Parent: Created child process 3420
[Fri Oct 07 12:59:38 2016] [notice] Child 3420: Child process is running
[Fri Oct 07 12:59:38 2016] [notice] Child 3420: Acquired the start mutex.
[Fri Oct 07 12:59:38 2016] [notice] Child 3420: Starting 64 worker threads.
[Fri Oct 07 12:59:38 2016] [notice] Child 3420: Starting thread to listen on port 80.
[Fri Oct 07 12:59:58 2016] [error] [client 127.0.0.1] File does not exist: C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/favicon.ico
[Fri Oct 07 12:59:59 2016] [error] [client 127.0.0.1] File does not exist: C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/favicon.ico
[Fri Oct 07 13:01:05 2016] [notice] Parent: Received shutdown signal -- Shutting down the server.
[Fri Oct 07 13:01:05 2016] [notice] Child 3420: Exit event signaled. Child process is ending.
[Fri Oct 07 13:01:06 2016] [notice] Child 3420: Released the start mutex
[Fri Oct 07 13:01:07 2016] [notice] Child 3420: All worker threads have exited.
[Fri Oct 07 13:01:07 2016] [notice] Child 3420: Child process is exiting
[Fri Oct 07 13:01:07 2016] [notice] Parent: Child process exited successfully.
[Fri Oct 07 13:07:27 2016] [warn] mod_wsgi: Compiled for Python/2.7.
[Fri Oct 07 13:07:27 2016] [warn] mod_wsgi: Runtime using Python/2.7.11.
[Fri Oct 07 13:07:27 2016] [notice] Apache/2.2.25 (Win32) mod_wsgi/3.3 Python/2.7.11 configured -- resuming normal operations
[Fri Oct 07 13:07:27 2016] [notice] Server built: Jul 10 2013 01:52:12
[Fri Oct 07 13:07:27 2016] [notice] Parent: Created child process 7712
[Fri Oct 07 13:07:28 2016] [warn] mod_wsgi: Compiled for Python/2.7.
[Fri Oct 07 13:07:28 2016] [warn] mod_wsgi: Runtime using Python/2.7.11.
[Fri Oct 07 13:07:28 2016] [notice] Child 7712: Child process is running
ImportError: No module named site
[Fri Oct 07 13:07:28 2016] [crit] (OS 1813)Der angegebene Ressourcentyp wurde nicht in der Image-Datei gefunden.  : master_main: create child process failed. Exiting.
[Fri Oct 07 13:42:17 2016] [notice] Apache/2.2.25 (Win32) configured -- resuming normal operations
[Fri Oct 07 13:42:17 2016] [notice] Server built: Jul 10 2013 01:52:12
[Fri Oct 07 13:42:17 2016] [notice] Parent: Created child process 5752
[Fri Oct 07 13:42:17 2016] [notice] Child 5752: Child process is running
[Fri Oct 07 13:42:17 2016] [notice] Child 5752: Acquired the start mutex.
[Fri Oct 07 13:42:17 2016] [notice] Child 5752: Starting 64 worker threads.
[Fri Oct 07 13:42:17 2016] [notice] Child 5752: Starting thread to listen on port 80.
[Fri Oct 07 13:42:28 2016] [notice] Parent: Received restart signal -- Restarting the server.
[Fri Oct 07 13:42:28 2016] [notice] Child 5752: Exit event signaled. Child process is ending.
[Fri Oct 07 13:42:28 2016] [notice] Apache/2.2.25 (Win32) configured -- resuming normal operations
[Fri Oct 07 13:42:28 2016] [notice] Server built: Jul 10 2013 01:52:12
[Fri Oct 07 13:42:28 2016] [notice] Parent: Created child process 5828
[Fri Oct 07 13:42:28 2016] [warn] mod_wsgi: Compiled for Python/2.7.9+.
[Fri Oct 07 13:42:28 2016] [warn] mod_wsgi: Runtime using Python/2.7.11.
[Fri Oct 07 13:42:28 2016] [notice] Child 5828: Child process is running
ImportError: No module named site
[Fri Oct 07 13:42:28 2016] [crit] (OS 1813)Der angegebene Ressourcentyp wurde nicht in der Image-Datei gefunden.  : master_main: create child process failed. Exiting.
[Fri Oct 07 13:42:29 2016] [notice] Child 5752: Released the start mutex
[Fri Oct 07 13:42:30 2016] [notice] Child 5752: All worker threads have exited.
[Fri Oct 07 13:42:30 2016] [notice] Child 5752: Child process is exiting
[Fri Oct 07 13:43:17 2016] [warn] mod_wsgi: Compiled for Python/2.7.9+.
[Fri Oct 07 13:43:17 2016] [warn] mod_wsgi: Runtime using Python/2.7.11.
[Fri Oct 07 13:43:17 2016] [notice] Apache/2.2.25 (Win32) mod_wsgi/4.4.12 Python/2.7.11 configured -- resuming normal operations
[Fri Oct 07 13:43:17 2016] [notice] Server built: Jul 10 2013 01:52:12
[Fri Oct 07 13:43:17 2016] [notice] Parent: Created child process 1200
[Fri Oct 07 13:43:17 2016] [warn] mod_wsgi: Compiled for Python/2.7.9+.
[Fri Oct 07 13:43:17 2016] [warn] mod_wsgi: Runtime using Python/2.7.11.
[Fri Oct 07 13:43:17 2016] [notice] Child 1200: Child process is running
ImportError: No module named site
[Fri Oct 07 13:43:17 2016] [crit] (OS 1813)Der angegebene Ressourcentyp wurde nicht in der Image-Datei gefunden.  : master_main: create child process failed. Exiting.
[Fri Oct 07 14:01:14 2016] [warn] mod_wsgi: Compiled for Python/2.7.9+.
[Fri Oct 07 14:01:14 2016] [warn] mod_wsgi: Runtime using Python/2.7.11.
[Fri Oct 07 14:01:14 2016] [notice] Apache/2.2.25 (Win32) mod_wsgi/4.4.12 Python/2.7.11 configured -- resuming normal operations
[Fri Oct 07 14:01:14 2016] [notice] Server built: Jul 10 2013 01:52:12
[Fri Oct 07 14:01:14 2016] [notice] Parent: Created child process 6128
[Fri Oct 07 14:01:14 2016] [warn] mod_wsgi: Compiled for Python/2.7.9+.
[Fri Oct 07 14:01:14 2016] [warn] mod_wsgi: Runtime using Python/2.7.11.
[Fri Oct 07 14:01:14 2016] [notice] Child 6128: Child process is running
ImportError: No module named site
[Fri Oct 07 14:01:14 2016] [crit] (OS 1813)Der angegebene Ressourcentyp wurde nicht in der Image-Datei gefunden.  : master_main: create child process failed. Exiting.
[Fri Oct 07 14:01:24 2016] [notice] Apache/2.2.25 (Win32) configured -- resuming normal operations
[Fri Oct 07 14:01:24 2016] [notice] Server built: Jul 10 2013 01:52:12
[Fri Oct 07 14:01:24 2016] [notice] Parent: Created child process 8268
[Fri Oct 07 14:01:24 2016] [notice] Child 8268: Child process is running
[Fri Oct 07 14:01:24 2016] [notice] Child 8268: Acquired the start mutex.
[Fri Oct 07 14:01:24 2016] [notice] Child 8268: Starting 64 worker threads.
[Fri Oct 07 14:01:24 2016] [notice] Child 8268: Starting thread to listen on port 80.
[Fri Oct 07 14:01:29 2016] [notice] Parent: Received shutdown signal -- Shutting down the server.
[Fri Oct 07 14:01:29 2016] [notice] Child 8268: Exit event signaled. Child process is ending.
[Fri Oct 07 14:01:30 2016] [notice] Child 8268: Released the start mutex
[Fri Oct 07 14:01:31 2016] [notice] Child 8268: All worker threads have exited.
[Fri Oct 07 14:01:31 2016] [notice] Child 8268: Child process is exiting
[Fri Oct 07 14:01:31 2016] [notice] Parent: Child process exited successfully.
[Mon Oct 10 09:37:29 2016] [warn] mod_wsgi: Compiled for Python/2.7.9+.
[Mon Oct 10 09:37:29 2016] [warn] mod_wsgi: Runtime using Python/2.7.11.
[Mon Oct 10 09:37:29 2016] [notice] Apache/2.2.25 (Win32) mod_wsgi/4.4.12 Python/2.7.11 configured -- resuming normal operations
[Mon Oct 10 09:37:29 2016] [notice] Server built: Jul 10 2013 01:52:12
[Mon Oct 10 09:37:29 2016] [notice] Parent: Created child process 1012
[Mon Oct 10 09:37:29 2016] [warn] mod_wsgi: Compiled for Python/2.7.9+.
[Mon Oct 10 09:37:29 2016] [warn] mod_wsgi: Runtime using Python/2.7.11.
[Mon Oct 10 09:37:29 2016] [notice] Child 1012: Child process is running
ImportError: No module named site
[Mon Oct 10 09:37:29 2016] [crit] (OS 1813)Der angegebene Ressourcentyp wurde nicht in der Image-Datei gefunden.  : master_main: create child process failed. Exiting.
[Mon Oct 10 09:37:55 2016] [notice] Apache/2.2.25 (Win32) configured -- resuming normal operations
[Mon Oct 10 09:37:55 2016] [notice] Server built: Jul 10 2013 01:52:12
[Mon Oct 10 09:37:55 2016] [notice] Parent: Created child process 6368
[Mon Oct 10 09:37:55 2016] [notice] Child 6368: Child process is running
[Mon Oct 10 09:37:55 2016] [notice] Child 6368: Acquired the start mutex.
[Mon Oct 10 09:37:55 2016] [notice] Child 6368: Starting 64 worker threads.
[Mon Oct 10 09:37:55 2016] [notice] Child 6368: Starting thread to listen on port 80.
[Mon Oct 10 09:38:14 2016] [notice] Parent: Received restart signal -- Restarting the server.
[Mon Oct 10 09:38:14 2016] [notice] Child 6368: Exit event signaled. Child process is ending.
[Mon Oct 10 09:38:15 2016] [notice] Apache/2.2.25 (Win32) configured -- resuming normal operations
[Mon Oct 10 09:38:15 2016] [notice] Server built: Jul 10 2013 01:52:12
[Mon Oct 10 09:38:15 2016] [notice] Parent: Created child process 7484
[Mon Oct 10 09:38:15 2016] [warn] mod_wsgi: Compiled for Python/2.7.9+.
[Mon Oct 10 09:38:15 2016] [warn] mod_wsgi: Runtime using Python/2.7.11.
[Mon Oct 10 09:38:15 2016] [notice] Child 7484: Child process is running
ImportError: No module named site
[Mon Oct 10 09:38:15 2016] [crit] (OS 1813)Der angegebene Ressourcentyp wurde nicht in der Image-Datei gefunden.  : master_main: create child process failed. Exiting.
[Mon Oct 10 09:38:15 2016] [warn] (OS 995)Der E/A-Vorgang wurde wegen eines Threadendes oder einer Anwendungsanforderung abgebrochen.  : winnt_accept: Asynchronous AcceptEx failed.
[Mon Oct 10 09:38:15 2016] [notice] Child 6368: Released the start mutex
[Mon Oct 10 09:38:16 2016] [notice] Child 6368: All worker threads have exited.
[Mon Oct 10 09:38:16 2016] [notice] Child 6368: Child process is exiting

我不确定问题到底出在哪里,因为 mod_wsg 是针对 Python 2.7 的,而且除了 Apache 2.2(32 位)之外,我还使用 Python 2.7(32 位)。

【问题讨论】:

    标签: python apache mod-wsgi


    【解决方案1】:

    解决了这个问题。

    我必须设置环境变量 PYTHONHOME 和 PYTHONPATH 来修复“ImportError: No module named site”错误。

    set PYTHONHOME=c:\Python27
    set PYTHONPATH=c:\Python27\Lib
    set PATH=%PYTHONHOME%;%PATH%
    

    【讨论】:

    • 您不需要设置这些。你所做的表明没有为机器的所有用户正确安装 Python。最好卸载 Python 并重新安装它,确保为所有用户安装它。
    猜你喜欢
    • 2015-08-19
    • 2011-04-02
    • 2015-03-21
    • 1970-01-01
    • 1970-01-01
    • 2012-01-03
    • 2013-12-23
    • 1970-01-01
    • 2014-07-27
    相关资源
    最近更新 更多