如何将Django应用程序部署到AWS的EC2

时间:2017-02-08 09:09:23

标签: python django amazon-web-services nginx amazon-ec2

前提·您想要实现的目标

我想将django应用程序部署到AWS的EC2。 服务器使用nginx。 我也在尝试使用uWSGI。 虚拟环境由virtualenv制作。 谢谢。

出现问题·错误消息

nginx的进程,wsgi正在运行,但是localhost无法运行该应用程序。 如果我点击curl,它将会出现内部服务器错误。

登录

!!! no internal routing support, rebuild with pcre support !!! 
chdir() to /opt/app/apolo_api 
your processes number limit is 3896 
your memory page size is 4096 bytes 
detected max file descriptor number: 1024 
lock engine: pthread robust mutexes 
thunder lock: enabled 
uWSGI http bound on :5001 fd 3 
uwsgi socket 0 bound to UNIX address /tmp/uwsgi.sock fd 6 
Python version: 3.5.1 (default, Sep 13 2016, 18:48:37)  [GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] 
Set PythonHome to /opt/app/venv/ 
Python main interpreter initialized at 0x225ace0 
python threads support enabled 
your server socket listen backlog is limited to 100 connections 
your mercy for graceful operations on workers is 60 seconds 
mapped 166112 bytes (162 KB) for 2 cores 
* Operational MODE: threaded * 
added /opt/app/apolo_api/api/ to pythonpath. 
unable to load app 0 (mountpoint='') (callable not found or import error) 
* no app loaded. going in full dynamic mode * 
* uWSGI is running in multiple interpreter mode * 
spawned uWSGI master process (pid: 22526) 
spawned uWSGI worker 1 (pid: 22527, cores: 2) 
* Stats server enabled on /tmp/uwsgi.stats.sock fd: 12 * 
spawned uWSGI http 1 (pid: 22528)

可能

* No app loaded. Going in full dynamic mode *

似乎它已停止在。部分开始了。

我尝试了什么

创建/etc/init/uwsgi_myproject.conf文件

Create /etc/init/uwsgi_myproject.conf file
description "uWSGI starter for myproject"

start on (local-filesystems and runlevel [2345]) 
stop on runlevel [016]

respawn

exec /usr/local/bin/uwsgi /etc/init/myproject.ini

创建/etc/init/myproject.ini文件

[uwsgi] 
chdir=/opt/app/myproject 
module='myproject.wsgi:application' 
socket = /tmp/uwsgi.sock 
env DJANGO_SETTINGS_MODULE=myproject.settings 
master = true 
uid = nginx 
gid = nginx 
http = :5001 
venv = /opt/app/venv/ 
python-path = /opt/app/apolo_api/api/ 
wsgi = app:app 
processes = 1 
threads = 2 
stats = /tmp/uwsgi.stats.sock 
memory-report = true 
thunder-lock = true 
max-requests = 500 
max-requests-delta = 30 
touch-reload=/tmp/.uwsgi_reload

谢谢。

0 个答案:

没有答案