Error: ImportError while deploying Flask app in wsgi file
Error: ImportError while deploying Flask app in wsgi file
我不知道我到底错过了什么。这是我到目前为止所拥有的:
wsgi
/opt/tools/apps/scheduler/scheduler.wsgi
其内容
from scheduler import app as application
init.py
/opt/tools/apps/scheduler/scheduler/__init__.py
Apache 日志错误
[Thu Feb 04 21:54:30 2016] [error] [client 10.57.136.99] mod_wsgi (pid=45485): Target WSGI script '/opt/tools/apps/scheduler/scheduler.wsgi' cannot be loaded as Python module.
[Thu Feb 04 21:54:30 2016] [error] [client 10.57.136.99] mod_wsgi (pid=45485): Exception occurred processing WSGI script '/opt/tools/apps/scheduler/scheduler.wsgi'.
[Thu Feb 04 21:54:30 2016] [error] [client 10.57.136.99] Traceback (most recent call last):
[Thu Feb 04 21:54:30 2016] [error] [client 10.57.136.99] File "/opt/tools/apps/scheduler/scheduler.wsgi", line 1, in <module>
[Thu Feb 04 21:54:30 2016] [error] [client 10.57.136.99] from scheduler import app as application
[Thu Feb 04 21:54:30 2016] [error] [client 10.57.136.99] ImportError: No module named scheduler
wsgi.conf
/etc/httpd/conf.d
LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonHome /opt/tools
WSGISocketPrefix run/wsgi
WSGIDaemonProcess scheduler user=abcd group=efgh processes=4
WSGIScriptAlias /scheduler /opt/tools/apps/scheduler/scheduler.wsgi
<Directory /opt/tools/apps/scheduler>
WSGIProcessGroup scheduler
WSGIApplicationGroup %{RESOURCE}
Order deny,allow
Allow from all
</Directory>
我关注了 & Link2 但运气不好。此应用程序在一台主机上正常工作(比如 host-1),我正在尝试将它部署在 host-2 上。
由于您的应用程序将 运行 作为守护程序,因此根目录将设置为 /
。
确保您的项目目录添加到 python PATH
或让 wsgi 运行 应用程序在正确的路径中。
你的 scheduler.wsgi
应该是这样的:
# insert application path in python path
import sys
sys.path.insert(0, "/opt/tools/apps/scheduler")
# launch app
from scheduler import app as application
还要确保 apache user/group (www-data
) 可以访问项目:
chown -R www-data:www-data /opt/tools/apps/scheduler
我不知道我到底错过了什么。这是我到目前为止所拥有的:
wsgi
/opt/tools/apps/scheduler/scheduler.wsgi
其内容
from scheduler import app as application
init.py
/opt/tools/apps/scheduler/scheduler/__init__.py
Apache 日志错误
[Thu Feb 04 21:54:30 2016] [error] [client 10.57.136.99] mod_wsgi (pid=45485): Target WSGI script '/opt/tools/apps/scheduler/scheduler.wsgi' cannot be loaded as Python module.
[Thu Feb 04 21:54:30 2016] [error] [client 10.57.136.99] mod_wsgi (pid=45485): Exception occurred processing WSGI script '/opt/tools/apps/scheduler/scheduler.wsgi'.
[Thu Feb 04 21:54:30 2016] [error] [client 10.57.136.99] Traceback (most recent call last):
[Thu Feb 04 21:54:30 2016] [error] [client 10.57.136.99] File "/opt/tools/apps/scheduler/scheduler.wsgi", line 1, in <module>
[Thu Feb 04 21:54:30 2016] [error] [client 10.57.136.99] from scheduler import app as application
[Thu Feb 04 21:54:30 2016] [error] [client 10.57.136.99] ImportError: No module named scheduler
wsgi.conf
/etc/httpd/conf.d
LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonHome /opt/tools
WSGISocketPrefix run/wsgi
WSGIDaemonProcess scheduler user=abcd group=efgh processes=4
WSGIScriptAlias /scheduler /opt/tools/apps/scheduler/scheduler.wsgi
<Directory /opt/tools/apps/scheduler>
WSGIProcessGroup scheduler
WSGIApplicationGroup %{RESOURCE}
Order deny,allow
Allow from all
</Directory>
我关注了
由于您的应用程序将 运行 作为守护程序,因此根目录将设置为 /
。
确保您的项目目录添加到 python PATH
或让 wsgi 运行 应用程序在正确的路径中。
你的 scheduler.wsgi
应该是这样的:
# insert application path in python path
import sys
sys.path.insert(0, "/opt/tools/apps/scheduler")
# launch app
from scheduler import app as application
还要确保 apache user/group (www-data
) 可以访问项目:
chown -R www-data:www-data /opt/tools/apps/scheduler