热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

将uwsgi配置参数从端口号改为socket文件,需要给uwsgi哪些权限?

第一遍这么输入的:uwsgi--socket:8001--wsgi-filetest.py没有问题

第一遍这么输入的:uwsgi --socket :8001 --wsgi-file test.py
没有问题



第二遍输入:uwsgi --socket mysite.sock --wsgi-file test.py
就不对了
bind(): Operation not permitted [core/socket.c line 230]
第二遍用新的参数重新启动uwsgi的时候出上面的报错

uwsgi --socket mysite.sock --wsgi-file test.py --chmod-socket=666
这样也不行



项目文件夹的读写权限如下:
drwxr-xr-x 1 vagrant vagrant 374 Feb 3 07:32 mysite/
显然写权限只属于vagrant用户。

那么我是否把整个项目文件夹的写权限全部允许给uwsgi就可以了?


Using Unix sockets instead of ports

So far we have used a TCP port socket, because it’s simpler, but in fact it’s better to use Unix sockets than ports - there’s less overhead.

Edit mysite_nginx.conf, changing it to match:

1
2
server unix:///path/to/your/mysite/mysite.sock; # for a file socket

# server 127.0.0.1:8001; # for a web port socket (we'll use this first) and restart nginx.

Run uWSGI again:

1
uwsgi --socket mysite.sock --wsgi-file test.py

This time the socket option tells uWSGI which file to use.

Try http://example.com:8000/ in the browser.

If that doesn’t work

Check your nginx error log(/var/log/nginx/error.log). If you see something like:

1
connect() to unix:///path/to/your/mysite/mysite.sock failed (13: Permission denied)

then probably you need to manage the permissions on the socket so that nginx is allowed to use it.

Try:

1
uwsgi --socket mysite.sock --wsgi-file test.py --chmod-socket=666 # (very permissive)

or:

1
uwsgi --socket mysite.sock --wsgi-file test.py --chmod-socket=664 # (more sensible)

You may also have to add your user to nginx’s group (which is probably www-data), or vice-versa, so that nginx can read and write to your socket properly.

It’s worth keeping the output of the nginx log running in a terminal window so you can easily refer to it while troubleshooting.



   



推荐阅读
author-avatar
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有