我一直关注http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html
然后去了
并启动了uwsgi --socket mysite.sock --module mysite.wsgi --chmod-socket = 664它已启动,但当我在浏览器上加载我的网页时 502 Bad Gateway
Django版本1.10.2
错误是
错误] 25444#25444:* 1 connect()失败(111:拒绝连接) 连接上游时,客户端:127.0.0.1,服务器:mytest.com, 请求:“GET / HTTP / 1.1”,上游:“uwsgi://127.0.0.1:8001”,主持人: “127.0.0.1:8000”
可能是什么问题?
# configuration of the server
server {
# the port your site will be served on
listen 8000;
# the domain name it will serve for
server_name mytest.com; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 175M; # adjust to taste
# Django media
location /media {
alias /home/karesh/tutorial/uwsgi-tutorial/mysite/media; # your Django project's media files - amend as required
}
location /static {
alias /home/karesh/tutorial/uwsgi-tutorial/mysite/static; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass unix:/home/karesh/tutorial/uwsgi-tutorial/mysite/mysite.sock;
include /home/karesh/tutorial/uwsgi-tutorial/mysite/uwsgi_params; # the uwsgi_params file you installed
}
}
项目目录中的uwsgi_params文件
uwsgi_param QUERY_STRING $query_string;
uwsgi_param REQUEST_METHOD $request_method;
uwsgi_param CONTENT_TYPE $content_type;
uwsgi_param CONTENT_LENGTH $content_length;
uwsgi_param REQUEST_URI $request_uri;
uwsgi_param PATH_INFO $document_uri;
uwsgi_param DOCUMENT_ROOT $document_root;
uwsgi_param SERVER_PROTOCOL $server_protocol;
uwsgi_param REQUEST_SCHEME $scheme;
uwsgi_param HTTPS $https if_not_empty;
uwsgi_param REMOTE_ADDR $remote_addr;
uwsgi_param REMOTE_PORT $remote_port;
uwsgi_param SERVER_PORT $server_port;
uwsgi_param SERVER_NAME $server_name;
答案 0 :(得分:0)
一些可以帮助你的事情:
1)将运行uWSGI的用户添加到nginx
组
2)在启用SE的CentOS上,放置套接字的最佳方法是/run
下的目录
3)将套接字权限设置为<your_user>:nginx
(换句话说 - 为您的用户和nginx组设置套接字权限。
这些步骤通常可以帮助我找出权限错误。