Python+uWSGI+nginx报错:Permission denied
折腾我好久了,老是提示没有权限:
-bash-4.1# > /var/log/nginx/error.log
-bash-4.1# curl 127.0.0.1:8080
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center>
<h1>502 Bad Gateway</h1>
</center>
<hr>
<center>nginx/1.6.2</center>
</body>
</html>
-bash-4.1# cat /var/log/nginx/error.log
2015/01/16 18:51:32 [crit] 4937#0: *1 connect() to 127.0.0.1:3301 failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: uwsgi_demo, request: "GET / HTTP/1.1", upstream: "uwsgi://127.0.0.1:3301", host: "127.0.0.1:8080"
测试程序:
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return ['Hello World']
测试程序目录情况:
-bash-4.1# ll
total 12
-rw-r--r--. 1 nginx nginx 139 Jan 16 15:34 app.py
-rw-r--r--. 1 root root 136 Jan 16 18:37 demo.ini
-rw-r-----. 1 root root 95 Jan 16 18:45 demo.log
uswgi 配置:
[uwsgi]
socket = 127.0.0.1:3031
wsgi-file = app.py
uid = nginx
gid = nginx
chmod-socket = 666
logto = demo.log
stats = 127.0.0.1:9191
nginx配制:
server {
listen 8080;
server_name uwsgi_demo;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:3301;
}
}
进程情况:
-bash-4.1# ps aux | grep nginx
nginx 4819 0.0 0.3 53996 6852 pts/4 S+ 18:48 0:00 uwsgi26 demo.ini
nginx 4821 0.0 0.3 73460 6048 pts/4 S+ 18:48 0:00 uwsgi26 demo.ini
root 4935 0.0 0.1 141788 2568 ? Ss 18:50 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 4937 0.0 0.1 142184 3292 ? S 18:50 0:00 nginx: worker process
root 4939 0.0 0.0 6380 692 pts/2 S+ 18:50 0:00 grep nginx
JrSeven
10 years, 1 month ago