我正在尝试在vps上部署Flask应用程序,其中OS是Debian,而且正在使用Apache . 我是Apache的新手,所以我的问题可能看起来很简单,但我无法在网上找到任何解决方案(我在这个论坛上阅读了几个教程并进行了搜索) .
服务器运行正常(它已用于其他目的) . 当我尝试使用www.myservername / web_app访问我的应用程序时,我收到404 Not Found错误 . 关于http://flask.pocoo.org/docs/0.12/deploying/mod_wsgi/,这是我所做的:
我将我的应用程序放在/ var / www / web_app /中 . 在/ var / www / web_app / app / init .py我创建了一个我的应用程序(名为app)的实例并对其进行了配置 .
我将以下.wsgi文件放在/ var / www / web_app /中:
activate_this = '/var/www/web_app/.pyenv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this)
import sys
from app import app as application
这是/etc/apache2/sites-available/000-default.conf文件(该站点已启用):
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory /var/www/html/redmine>
RailsBaseURI /redmine
PassengerResolveSymlinksInDocumentRoot on
</Directory>
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
WSGIDaemonProcess app user=www-data group=www-data threads=5
WSGIScriptAlias /web_app /var/www/web_app/app.wsgi
<Directory /var/www/web_app>
WSGIProcessGroup app
WSGIApplicationGroup %{GLOBAL}
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
我还尝试用WSGIScriptAlias中的/ var / www / web_app替换/ web_app,并访问myservername / var / www / web_app . 此外,我试图在第一个Directory标记中注释掉Rails / Passenger指令 .
当然我安装了wsgi模块 . 我在尝试访问该页面之前重新启动了服务器 . 这是访问日志:
... "GET /web_app HTTP/1.1" 404 508
和错误日志:
[error] ... File does not exist : /var/www/web_app
最后,我的烧瓶应用 - 当使用烧瓶开发服务器 - 工作正常 .
谢谢你的帮助!