我正在尝试配置Apache来重新部署我的Flask应用程序。它运行如果我运行命令“python flaskapp.py”,但使用Apache它无法导入内部模块工具
这是我的烧瓶应用
from flask import Flask
app = Flask(__name__)
import sys
sys.path.append('tools')
import Tools #if i comment this line, not error display and app works ok!
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run()
这是我的.conf文件
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
WSGIDaemonProcess flaskapp python-path=/var/www/html/flaskapp
WSGIScriptAlias / /var/www/html/flaskapp/flaskapp.wsgi process-group=flaskapp application-group=%{GLOBAL}
<Directory /var/www/html/flaskapp>
<Files flaskapp.wsgi>
Order allow,deny
Allow from all
</Files>
</Directory>
Alias /static /var/www/html/flaskapp/static
<Directory /var/www/html/flaskapp/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
我的wsgi文件
import sys
sys.path.insert(0, '/var/www/html/flaskapp')
from flaskapp import app as application
我的应用文件夹ar / var / www / html /
flaskapp/
-flaskapp.py
-flaskapp.wsgi
-static/
-templates/
-tools/
-Tools.py
错误日志
[Thu Mar 09 18:23:23.634661 2017] [wsgi:error] [pid 3711:tid 140422583609088] [remote 200.69.225.201:9142] mod_wsgi (pid=3711): Target WSGI script '/var/www/html/flaskapp/flaskapp.wsgi' cannot be loaded as Python module.
[Thu Mar 09 18:23:23.634694 2017] [wsgi:error] [pid 3711:tid 140422583609088] [remote 200.69.225.201:9142] mod_wsgi (pid=3711): Exception occurred processing WSGI script '/var/www/html/flaskapp/flaskapp.wsgi'.
[Thu Mar 09 18:23:23.634719 2017] [wsgi:error] [pid 3711:tid 140422583609088] [remote 200.69.225.201:9142] Traceback (most recent call last):
[Thu Mar 09 18:23:23.634734 2017] [wsgi:error] [pid 3711:tid 140422583609088] [remote 200.69.225.201:9142] File "/var/www/html/flaskapp/flaskapp.wsgi", line 4, in <module>
[Thu Mar 09 18:23:23.634755 2017] [wsgi:error] [pid 3711:tid 140422583609088] [remote 200.69.225.201:9142] from flaskapp import app as application
[Thu Mar 09 18:23:23.634762 2017] [wsgi:error] [pid 3711:tid 140422583609088] [remote 200.69.225.201:9142] File "/var/www/html/flaskapp/flaskapp.py", line 6, in <module>
[Thu Mar 09 18:23:23.634771 2017] [wsgi:error] [pid 3711:tid 140422583609088] [remote 200.69.225.201:9142] import Tools
[Thu Mar 09 18:23:23.634783 2017] [wsgi:error] [pid 3711:tid 140422583609088] [remote 200.69.225.201:9142] ImportError: No module named Tools