2016-08-26 64 views
1

我在ubuntu AWS服务器上托管Django站点时遇到了一些问题。我已经在本地主机上运行好了。在AWS上部署Django时缺少模块Ubuntu EC2

我以下说明:https://github.com/ialbert/biostar-central/blob/master/docs/deploy.md

当我尝试和AWS控制台运行它使用:如果我用

1. No module named simple_wsgi 

然后:

waitress-serve --port 8080 live.deploy.simple_wsgi:application 

我得到导入错误基地设置文件(不是减少一个),我得到导入错误

1. No module named logger 

我试着移动设置文件并将设置文件复制到deploy.env和deploy.py,然后sample.env和sample.py,我无法启动它。请帮助

+1

是在第一种情况下丢失的依赖。使用“pip install simple_wsgi”或在您的配置文件中提及simple_wsgi。 –

回答

0

我有同样的问题和opened it in Biostar project

下面是我如何修复它:通过gunicornnginx提供应用程序。

这里是我的脚本:

cp live/staging.env live/deploy.env 
cp live/staging.py live/deploy.py 
# Replace the value of DJANGO_SETTINGS_MODULE to "live.deploy" thanks to http://stackoverflow.com/a/5955623/535203 
sed -i -e '/DJANGO_SETTINGS_MODULE=/ s/=.*/=live.deploy/' live/deploy.env 
[[ -n "$BIOSTAR_HOSTNAME" ]] && sed -i -e "/BIOSTAR_HOSTNAME=/ s/=.*/=$BIOSTAR_HOSTNAME/" live/deploy.env 
source live/deploy.env 
biostar.sh init import 
# Nginx config based on http://docs.gunicorn.org/en/stable/deploy.html and https://github.com/ialbert/biostar-central/blob/production/conf/server/biostar.nginx.conf 
tee "$LIVE_DIR/nginx.conf" <<EOF 
worker_processes 1; 

user nobody nogroup; 
# 'user nobody nobody;' for systems with 'nobody' as a group instead 
pid /tmp/nginx.pid; 
error_log /tmp/nginx.error.log; 

events { 
    worker_connections 1024; # increase if you have lots of clients 
    accept_mutex off; # set to 'on' if nginx worker_processes > 1 
    # 'use epoll;' to enable for Linux 2.6+ 
    # 'use kqueue;' to enable for FreeBSD, OSX 
} 

http { 
    include /etc/nginx/mime.types; 
    # fallback in case we can't determine a type 
    default_type application/octet-stream; 
    access_log /tmp/nginx.access.log combined; 
    sendfile on; 

    upstream app_server { 
    # fail_timeout=0 means we always retry an upstream even if it failed 
    # to return a good HTTP response 

    # for UNIX domain socket setups 
    server unix:/tmp/biostar.sock fail_timeout=0; 

    # for a TCP configuration 
    # server 192.168.0.7:8000 fail_timeout=0; 
    } 

    server { 
    # if no Host match, close the connection to prevent host spoofing 
    listen 8080 default_server; 
    return 444; 
    } 

    server { 
    # use 'listen 80 deferred;' for Linux 
    # use 'listen 80 accept_filter=httpready;' for FreeBSD 
    listen 8080; 
    client_max_body_size 5M; 

    # set the correct host(s) for your site 
    server_name $SITE_DOMAIN; 

    keepalive_timeout 25s; 

    # path for static files 
    root $LIVE_DIR/export/; 
    location = /favicon.ico { 
     alias $LIVE_DIR/export/static/favicon.ico; 
    } 

    location = /sitemap.xml { 
     alias $LIVE_DIR/export/static/sitemap.xml; 
    } 

    location = /robots.txt { 
     alias $LIVE_DIR/export/static/robots.txt; 
    } 

    location /static/ { 
     autoindex on; 
     expires max; 
     add_header Pragma public; 
     add_header Cache-Control "public"; 
     access_log off; 
    } 

    location/{ 
     # checks for static file, if not found proxy to app 
     try_files \$uri @proxy_to_app; 
    } 

    location @proxy_to_app { 
     proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; 
     # enable this if and only if you use HTTPS 
     # proxy_set_header X-Forwarded-Proto https; 
     proxy_set_header Host \$http_host; 
     # we don't want nginx trying to do something clever with 
     # redirects, we set the Host: header above already. 
     proxy_redirect off; 
     proxy_pass http://app_server; 
    } 
    } 
} 
EOF 

gunicorn -b unix:/tmp/biostar.sock biostar.wsgi & 
# Start Nginx in non daemon mode thanks to http://stackoverflow.com/a/28099946/535203 
nginx -g 'daemon off;' -c "$LIVE_DIR/nginx.conf"