Apache 2.4.10和mod-wsgi 4.4环境。
以下是apache错误日志文件:
[Wed Nov 02 11:15:21.360055 2016] [wsgi:error] [pid 3729:tid 140033629607680] [remote 10.10.200.99:7425] mod_wsgi (pid=3729): Target WSGI script '/home/service/was/test/test_app.wsgi' cannot be loaded as Python module.
[Wed Nov 02 11:15:21.360060 2016] [wsgi:error] [pid 3729:tid 140033629607680] [remote 10.10.200.99:7425] mod_wsgi (pid=3729): Exception occurred processing WSGI script '/home/service/was/test/test_app.wsgi'.
[Wed Nov 02 11:15:21.360067 2016] [wsgi:error] [pid 3729:tid 140033629607680] [remote 10.10.200.99:7425] Traceback (most recent call last):
[Wed Nov 02 11:15:21.360075 2016] [wsgi:error] [pid 3729:tid 140033629607680] [remote 10.10.200.99:7425] File "/home/service/was/test/test_app.wsgi", line 6, in <module>
[Wed Nov 02 11:15:21.360119 2016] [wsgi:error] [pid 3729:tid 140033629607680] [remote 10.10.200.99:7425] from test_app import app as application
[Wed Nov 02 11:15:21.360125 2016] [wsgi:error] [pid 3729:tid 140033629607680] [remote 10.10.200.99:7425] File "/home/service/was/test/test_app.py", line 3, in <module>
[Wed Nov 02 11:15:21.360141 2016] [wsgi:error] [pid 3729:tid 140033629607680] [remote 10.10.200.99:7425] from flask import Flask
[Wed Nov 02 11:15:21.360158 2016] [wsgi:error] [pid 3729:tid 140033629607680] [remote 10.10.200.99:7425] ImportError: No module named flask
我设置httpd-virtualhost.conf
:
Listen 10003
<VirtualHost *:10003>
# mod_wsgi global settings
WSGIApplicationGroup %{RESOURCE}
ErrorLog "|/usr/local/server/apache/bin/rotatelogs /home/log/apache/error-%Y-%m-%d.log 86400 +540"
TransferLog "|/usr/local/server/apache/bin/rotatelogs /home/log/apache/checkout/access-%Y-%m-%d.log 86400 +540"
#mod-wsgi : test
WSGIScriptAlias /test /home/service/was/test/test_app.wsgi
WSGIDaemonProcess test_app processes=4 threads=4 display-name=%{GROUP}
<Directory /home/service/was/test/ >
WSGIProcessGroup test_app
Require all granted
</Directory>
</VirtualHost>
我的wsgi脚本,test_App.wsgi
和test_app.py
:
#test_app.wsgi
import os, sys
os.environ['PYTHON_EGG_CACHE'] = '/tmp'
sys.path.insert(0, '/home/service/was/test/')
print os
print sys
from test_app import app as application
在此设置中,我在dev-server中运行test_app.py。
为什么要生成&#39;目标WSGI脚本&#39; /home/service/was/test/test_app.wsgi'无法作为Python模块加载。&#39;信息?
为什么不导入pip安装的python模块?