【发布时间】:2018-07-20 20:38:49
【问题描述】:
我在使用 mod_wsgi 部署我的烧瓶应用程序时出错。这是错误日志:
[Sat Feb 10 01:58:24.785611 2018] [wsgi:error] [pid 17184:tid 140591748056832] [remote 41.36.31.164:45065] mod_wsgi (pid=17184): Target WSGI script '/var/www/itemcatalog/itemcatalog.wsgi' cannot be loaded as Python module.
[Sat Feb 10 01:58:24.785635 2018] [wsgi:error] [pid 17184:tid 140591748056832] [remote 41.36.31.164:45065] mod_wsgi (pid=17184): Exception occurred processing WSGI script '/var/www/itemcatalog/itemcatalog.wsgi'.
[Sat Feb 10 01:58:24.785649 2018] [wsgi:error] [pid 17184:tid 140591748056832] [remote 41.36.31.164:45065] Traceback (most recent call last):
[Sat Feb 10 01:58:24.785664 2018] [wsgi:error] [pid 17184:tid 140591748056832] [remote 41.36.31.164:45065] File "/var/www/itemcatalog/itemcatalog.wsgi", line 6, in <module>
[Sat Feb 10 01:58:24.785710 2018] [wsgi:error] [pid 17184:tid 140591748056832] [remote 41.36.31.164:45065] from itemcatalog import app as application
[Sat Feb 10 01:58:24.785729 2018] [wsgi:error] [pid 17184:tid 140591748056832] [remote 41.36.31.164:45065] ImportError: No module named itemcatalog
我在 itemcatalog 目录中有一个 init.py 文件,我做了一些搜索,发现可能 python 没有将我的 itemcatalog 识别为包,这是什么原因?
Python 是全局安装的,但后来我也尝试将它安装在虚拟环境中。
这是虚拟主机的代码:
<VirtualHost *:80>
ServerName 18.194.244.229
ServerAdmin admin@18.194.244.229
WSGIDaemonProcess itemcatalog python-path=/var/www/itemcatalog:/var/www/itemcatalog/venv/lib/python2.7/site-packages
WSGIProcessGroup itemcatalog
WSGIScriptAlias / /var/www/itemcatalog/itemcatalog.wsgi
<Directory /var/www/itemcatalog/>
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
这是/var/www/itemcatalog/里面的文件结构
【问题讨论】:
标签: python apache flask apache2 mod-wsgi