我正在尝试使用 Nginx + uWSGI 在 Amazon EC2 上设置 Django 应用程序。
遵循这些基本教程
https://uwsgi.readthedocs.org/en/latest/tutorials/Django_and_nginx.html http://www.yaconiello.com/blog/setting-aws-ec2-instance-nginx-django-uwsgi-and-mysql/# stash.TsdnEDM8.oK2geOwb.dpbs
Nginx 欢迎页面出现 ok,Instance is running,Loadbalancer is In Service,Route53 对 loadbalancer 的别名。但我看不到我的应用程序...
该应用程序似乎正在运行。我已经在本地进行了测试,并且可以正常工作。
我在终端上输入
uwsgi --ini myproject_uwsgi.ini
得到这个
[uWSGI] getting INI configuration from myproject_uwsgi.ini
*** Starting uWSGI 1.9.15 (64bit) on [Wed Sep 11 06:14:04 2013] ***
compiled with version: 4.7.3 on 10 September 2013 09:27:00
os: Linux-3.8.0-19-generic #29-Ubuntu SMP Wed Apr 17 18:16:28 UTC 2013
nodename: ip-10-252-80-160
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /home/ubuntu/myproject
writing pidfile to /tmp/myproject-master.pid
detected binary path: /usr/local/bin/uwsgi
your processes number limit is 4569
your memory page size is 4096 bytes
*** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers ***
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
uwsgi socket 0 bound to UNIX address /tmp/myproject.sock fd 3
Python version: 2.7.4 (default, Apr 19 2013, 18:30:41) [GCC 4.7.3]
Set PythonHome to /home/ubuntu/.virtualenvs/myproject
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x1235b30
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 363880 bytes (355 KB) for 4 cores
*** Operational MODE: preforking ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x1235b30 pid: 1500 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1500)
spawned uWSGI worker 1 (pid: 1501, cores: 1)
spawned uWSGI worker 2 (pid: 1502, cores: 1)
spawned uWSGI worker 3 (pid: 1503, cores: 1)
spawned uWSGI worker 4 (pid: 1504, cores: 1)
我尝试查看error.log,但我什么也没得到...
编辑
myproject_uwsgi.ini
[uwsgi]
# Django-related settings
chdir = /home/ubuntu/myproject
module = myproject.wsgi
home = /home/ubuntu/.virtualenvs/myproject
env = DJANGO_SETTINGS_MODULE=myproject.settings
# process-related settings
master = true
processes = 4
socket = /tmp/myproject.sock
chmod-socket = 664
harakiri = 20
vacuum = true
max-requests = 5000
pidfile = /tmp/myproject-master.pid
daemonize = /home/ubuntu/myproject/log/myproject.log
myproject_nginx.conf
# the upstream component nginx needs to connect to
upstream django {
server unix:///tmp/myproject.sock;
# server 127.0.0.1:8001;
}
# configuration of the server
server {
listen 80;
server_name myproject.com www.myproject.com;
charset utf-8;
root /home/ubuntu/myproject/;
client_max_body_size 75M;
location /media {
alias /home/ubuntu/myproject/myproject/media;
}
location /static {
alias /home/ubuntu/myproject/myproject/static;
}
location / {
uwsgi_pass unix:///tmp/myproject.sock;
include /home/ubuntu/myproject/uwsgi_params;
}
}
`