如何在Webfaction上部署Flask应用程序? [英] How deploy Flask application on Webfaction?

查看:177
本文介绍了如何在Webfaction上部署Flask应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何在Webfaction上部署简单的Flask应用程序吗? 我知道Webfaction支持mod_wsgi,并且在Flask网站上阅读了该指南,但仍然无法使我的应用正常运行.有人有有效的配置吗?

Anybody know how to deploy a simple Flask application on Webfaction? I know Webfaction support mod_wsgi and I read the guide on the Flask site but still I can't make my app working. Anybody have a working configuration?

更新以回答Graham Dumpleton的评论.

UPDATE to answer a comment by Graham Dumpleton.

我收到500内部服务器错误. Apache在日志中未显示任何错误. WSGI脚本已执行,并且似乎可以正确创建应用程序,但是我一直收到500错误.

I get a 500 Internal server error. Apache does not show any error in the logs. The WSGI script is executed and seems to create the application correctly, but I keep getting a 500 error.

谢谢.

推荐答案

我通过以下过程进行操作:

I got it working with the following procedure:

  • 创建并命名为mod_wsgi 3.3/Python 2.7类型的名为"myapp"的应用. Webfaction将创建以下文件夹:

  • create and app named 'myapp' of type mod_wsgi 3.3/Python 2.7. Webfaction will create the following folders:

myapp
     |- apache2
     |- htdocs

  • Webfaction还将在您的htdocs目录中自动创建一个简单的脚本index.py.检查示例脚本是否在访问新创建的应用程序的根目录下工作(要对Webfaction进行精简,您需要在网站上挂载"该应用程序).如果一切正常,请修改脚本以删除内容并添加:

  • Webfaction will also automatically create a simple script index.py in your htdocs directory. Check if the sample script work visiting the root of your newly created application (to do thin on Webfaction you need to "mount" the app on a website). If it's all OK modify the script deleting the content and adding:

    from myapp import app as application
    

  • apache2/conf/httpd.conf中添加以下几行:

  • In apache2/conf/httpd.conf add the follwing lines:

    WSGIPythonPath /home/username/webapps/myapp/htdocs/
    #If you do not specify the next directive the app *will* work but you will
    #see index.py in the path of all subdir
    WSGIScriptAlias / /home/username/webapps/myapp/htdocs/index.py
    
    
    <Directory /home/username/webapps/myapp/htdocs>
        AddHandler wsgi-script .py
        RewriteEngine on
        RewriteBase /
        WSGIScriptReloading On
    </Directory>
    

  • 重新启动apache2

  • Restart apache2

    这篇关于如何在Webfaction上部署Flask应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆