django nginx uwsgi 部署在centos6.8上怎么总是出现502错误
本来是一直用apache mod_wsgi部署的。。最近换了个vps,想用nginx
django nginx uwsgi 部署在centos6.8上怎么总是出现502错误
下面是设置的情况
在项目目录下建 uwsgi.ini
# myweb_uwsgi.ini file
[uwsgi]
#django-related settings
socket = :8002
# the base directory (full path)
chdir = /var/wwwroot/html/cn94x
# Django s wsgi file
module = cn94x.wsgi
# process-related settings
# master
master = true
# maximum number of worker processes
processes = 4
# ... with appropriate permissions - may be needed
# chmod-socket = 664
# clear environment on exit
vacuum = true
启动:uwsgi --ini uwsgi.ini
[uWSGI] getting INI configuration from uwsgi.ini
*** Starting uWSGI 2.0.15 (32bit) on [Sat Aug 19 12:33:38 2017] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-18) on 18 August 2017 21:31:24
os: Linux-2.6.32-696.6.3.el6.i686 #1 SMP Wed Jul 12 13:38:41 UTC 2017
nodename: localhost.localdomain
machine: i686
clock source: unix
detected number of CPU cores: 1
current working directory: /var/wwwroot/html/cn94x
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to /var/wwwroot/html/cn94x
your processes number limit is 7914
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 :8002 fd 3
Python version: 2.7.13 (default, Aug 18 2017, 12:30:06) [GCC 4.4.7 20120313 (Red Hat 4.4.7-18)]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x9d400d8
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 319940 bytes (312 KB) for 4 cores
*** Operational MODE: preforking ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x9d400d8 pid: 2183 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 2183)
spawned uWSGI worker 1 (pid: 2185, cores: 1)
spawned uWSGI worker 2 (pid: 2186, cores: 1)
spawned uWSGI worker 3 (pid: 2187, cores: 1)
spawned uWSGI worker 4 (pid: 2188, cores: 1)
/etc/nginx/nginx.conf 里
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
server_name www.94x.cn;
charset UTF-8;
access_log /var/log/nginx/cn94x_access.log;
error_log /var/log/nginx/cn94x_error.log;
client_max_body_size 75M;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:8002;
uwsgi_read_timeout 2;
}
location /static {
expires 30d;
autoindex on;
add_header Cache-Control private;
alias /var/wwwroot/html/cn94x/static/;
}
}
}
关了防火墙
刚开始还可以。只是提示mysql数据库密码不对。
我的密码设置的: sdut!@# 这个明明是对的。
不知是哪里设置的还有问题?
还有几个不明白的地方。刚安装的 yum install nginx 怎么没有
etc/sites-available /etc/nginx/sites-enabled 这两个目录呢?
我是在/etc/nginx/nginx.conf里配置的 是不是可以手动创建?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看nginx的log,看一下报什么错
502 是 Bad Gateway。查看 nginx 的错误日志来确定 nginx 为什么没连上后端服务。
你 yum 装的没有那两个目录就没有呗。不同发行版的配置不太一样。手动创建的话你还要手动在主配置里边 include。