烧瓶app不会在ubuntu 12.04(数字海洋)上运行

时间:2014-08-27 05:28:24

标签: python apache flask mod-wsgi wsgi

我在运行ubuntu 12.04,apache2和mod-wsgi的数字海洋服务器上部署基本烧瓶应用程序时遇到了困难。我已经尝试了myapp.conf文件和myapp.wsgi文件的许多不同修改。我怀疑这些是罪魁祸首,但现在我不太确定。

始终,访问我的网址只会显示apache'它的工作原理是'对话。每次尝试成功重启apache服务(尝试修复问题后),并访问网站都会在error.log中看到相同的活动:

[Wed Aug 27 00:49:14 2014] [notice] caught SIGTERM, shutting down
[Wed Aug 27 00:49:15 2014] [notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations

此活动在access.log中:

11.22.33.44 - - [27/Aug/2014:00:49:19 -0400] "GET / HTTP/1.1" 304 209 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36"
11.22.33.44 - - [27/Aug/2014:00:49:21 -0400] "GET / HTTP/1.1" 304 208 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36"
11.22.33.44 - - [27/Aug/2014:00:49:24 -0400] "GET / HTTP/1.1" 304 208 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36"

基本'烧瓶app,我的意思是:没有sql数据库(没有,不像非关系),没有网站用户,没有工厂,没有蓝图等。

相关目录/ var / www / myapp /看起来像这样(使用virtualenv来运行应用程序):

myapp/
  + myapp/
  |    + static/
  |    + templates/
  |    + venv/
  |    | __init__.py
  | myapp.wsgi

虽然我已经尝试了几个版本的myapp.conf文件,但这两个版本具有代表性:

<VirtualHost *:80>
        ServerName myapp.com
        WSGIDaemonProcess myapp user=flask group=www-data home=/var/www/myapp/
        WSGIScriptAlias / /var/www/myapp/myapp.wsgi
        <Directory /var/www/myapp/myapp/>
            WSGIProcessGroup myapp
            WSGIApplicationGroup % {GLOBAL}
            WSGIScriptReloading On
            Order allow,deny
            Allow from all
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:80>
        ServerName myapp.com
        WSGIScriptAlias / /var/www/myapp/myapp.wsgi

        <Directory /var/www/myapp/myapp/>
            Order allow,deny
            Allow from all
        </Directory>
        Alias /static /var/www/myapp/myapp/static
        <Directory /var/www/myapp/myapp/static/>
            Order allow,deny
            Allow from all
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

我尝试过的两种常见类型的myapp.wsgi文件是:

#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/myapp/")

from myapp import app as application

activate_this = '/var/www/myapp/myapp/venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))

import os
import sys
import logging

logging.basicConfig(stream=sys.stderr)

sys.path.insert(0, '/var/www/myapp/')

from myapp import app as application

#commenting out same in __init__.py
if __name__ == '__main__':
    application.run()

该应用程序在我的本地计算机上运行成功,并且我总是为.conf文件中标识的每个用户取消/ var / www /目录。

任何想法,提示,指示等都非常受欢迎。非常感谢。

0 个答案:

没有答案