CentOS 7.4 Nginx 502 找不到/tmp下面的sock问题修复
Linux系统的权限问题,常常折磨着我们这些开发人员,所以我在启动Django项目的uwsgi时,也总是把pid和socket文件放到/tmp下面,但是,今后如果要用CentOS(运维的最爱,dont know why)系统来部署的话,就不行了,因为你会遇到如下的502
connect() to unix:/tmp/xxx.sock failed (2: No such file or directory) while connecting to upstream
然后你不断的问自己“我到底哪里错了”,并持续数个小时,然后偶然发现如下的信息:
it appears that programs that create files in /tmp (or /var/tmp as I have discovered) are the only programs that are able to see the files in that directory.
意思是,tmp不再是那个tmp了,某个程序(uwsgi)在里面创建的文件以后只能该程序自己看到,其他程序(nginx)就是睁眼瞎了(No such file or directory),所以会出现上面描述的问题,解决方法就是:放到别的文件夹里。🙂
参考: https://stackoverflow.com/questions/22272943/nginx-cannot-find-unix-socket-file-with-unicorn-no-such-file-or-directory https://serverfault.com/questions/463993/nginx-unix-domain-socket-error/464025#464025 http://fedoraproject.org/wiki/Features/ServicesPrivateTmp