我正在尝试使用nginx和uwsgi设置我的Django(2.0)项目,但它在运行时失败:
uwsgi --socket :8001 --wsgi-file test.py
在https://uwsgi.readthedocs.io/en/latest/tutorials/Django_and_nginx.html之后
它失败了,无法连接服务器,但是
uwsgi --http :8000 --wsgi-file test.py
没问题
这是我的uwsgi日志:
(venv) ubuntu@VM-49-116-ubuntu:~/code/blog/mmxy$ uwsgi --socket :8001 --wsgi-file test.py
*** Starting uWSGI 2.0.17 (64bit) on [Wed Apr 11 02:19:40 2018] ***
compiled with version: 5.4.0 20160609 on 09 April 2018 17:37:14
os: Linux-4.4.0-91-generic #114-Ubuntu SMP Tue Aug 8 11:56:56 UTC 2017
nodename: VM-49-116-ubuntu
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /home/ubuntu/code/blog/mmxy
detected binary path: /home/ubuntu/code/blog/venv/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 3306
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address :8001 fd 3
Python version: 3.6.4 (default, Apr 10 2018, 00:02:46) [GCC 5.4.0 20160609]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0xe92290
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72920 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0xe92290 pid: 8870 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 8870, cores: 1)
nginx conf:
upstream django {
# server unix:///tmp/mmxy.sock;
server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
server {
listen 8000;
server_name 140.143.242.243;
# server_name sususuus.xyz;
charset utf-8;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
# max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /home/ubuntu/code/blog/mmxy/media;
}
location /static {
alias /home/ubuntu/code/blog/mmxy/static;
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /etc/nginx/uwsgi_params;
}
}
当我连接我的服务器名时,nginx有'欢迎使用nginx'
我认为我的nginx conf有些不对劲但与文档相同