我正在尝试使用mod_wsgi在Digitalocean Dropplet(ubuntu 16.04)上部署flask应用程序。 我让它在运行相同软件(ubuntu 16.04,apache2.4,python 2.7等)的计算机上本地运行。所以我想我只是复制文件。令人沮丧和沮丧的是,这并不成功。 (通过IP_ADD /)访问服务器仅列出/ var / www / html /中的文件夹。 apache的error.log或access.log中没有有用的输出。仅有这样的警告:
[Sun Sep 02 08:09:32.230540 2018] [wsgi:warn] [pid 27342] mod_wsgi: Compiled for Python/2.7.11.
[Sun Sep 02 08:09:32.230565 2018] [wsgi:warn] [pid 27342] mod_wsgi: Runtime using Python/2.7.12.
但是我也将它们放在本地计算机上,并且运行顺利。
无论如何...请提供任何指针来解决此问题,甚至只是如何进行调试。
/var/www/fgl_flask/app3.py
from flask import Flask, request, jsonify, render_template
app = Flask(__name__)
@app.route('/', methods=["GET"])
def index():
return "Hello World!"
if __name__ == '__main__':
app.run()
flaskapp.wsgi
#!/usr/bin/python
import sys
import logging
import os
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/fgl_flask")
from app3 import app as application
apache2 / sites-enabled / fglf.conf
<VirtualHost *:80>
ServerAdmin webmaster@adentist.com
ServerName localhost
WSGIDaemonProcess fgl_flask user=www-data group=www-data threads=5
WSGIProcessGroup fgl_flask
WSGIScriptAlias / /var/www/fgl_flask/flaskapp.wsgi
Alias /static /var/www/fgl_flask/static
<Directory /var/www/fgl_flask/static>
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
apache LogLevel调试
[Mon Sep 03 08:24:12.949558 2018] [wsgi:info] [pid 29908] mod_wsgi (pid=29908): Attach interpreter ''.
[Mon Sep 03 08:24:12.954991 2018] [wsgi:debug] [pid 29908] src/server/mod_wsgi.c(7971): mod_wsgi (pid=29908): Started thread 0 in daemon process 'ftest'.
[Mon Sep 03 08:24:12.955036 2018] [wsgi:debug] [pid 29908] src/server/mod_wsgi.c(7971): mod_wsgi (pid=29908): Started thread 1 in daemon process 'ftest'.
[Mon Sep 03 08:24:12.955053 2018] [wsgi:debug] [pid 29908] src/server/mod_wsgi.c(7971): mod_wsgi (pid=29908): Started thread 2 in daemon process 'ftest'.
[Mon Sep 03 08:24:12.955064 2018] [wsgi:debug] [pid 29908] src/server/mod_wsgi.c(7971): mod_wsgi (pid=29908): Started thread 3 in daemon process 'ftest'.
[Mon Sep 03 08:24:12.955074 2018] [wsgi:debug] [pid 29908] src/server/mod_wsgi.c(7971): mod_wsgi (pid=29908): Started thread 4 in daemon process 'ftest'.