天天看点

centos下解决nginx 无法连接gitlab socket

<code>[root@liantu_61 home]</code><code># cat /etc/redhat-release </code>

<code>CentOS release 6.7 (Final)</code>

错误日志:

<code>2016</code><code>/01/29</code> <code>17:36:20 [crit] 27282</code><code>#0: *1 connect() to unix:/home/git/gitlab/tmp/sockets/gitlab.socket failed (13: Permission denied) while connecting to upstream, client: 192.168.xxx.xxx, server: test61.com, request: "GET /5755/my/notes?target_id=918a696a0e2340c2ee95402fa59187926edaae0c&amp;target_type=commit HTTP/1.1", upstream: "http://unix:/home/git/gitlab/tmp/sockets/gitlab.socket:/502.html", host: "test61.com", referrer: "http://test61.com/"</code>

nginx信息:

<code>[root@xxx_61 home]</code><code># ps aux|grep nginx</code>

<code>root     27280  0.0  0.0  17668   944 ?        Ss   17:35   0:00 nginx: master process </code><code>/usr/local/nginx/sbin/nginx</code> <code>-c </code><code>/usr/local/nginx/conf/nginx</code><code>.conf</code>

<code>www      27281  0.0  0.0  18096  1652 ?        S    17:35   0:00 nginx: worker process                                          </code>

<code>www      27282  0.0  0.0  18404  2192 ?        S    17:35   0:00 nginx: worker process                                          </code>

<code>www      27283  0.0  0.0  18096  1652 ?        S    17:35   0:00 nginx: worker process                                          </code>

<code>www      27284  0.0  0.0  18096  1636 ?        S    17:35   0:00 nginx: worker process                                          </code>

<code>root     27531  0.0  0.0 103304   936 pts</code><code>/0</code>    <code>S+   17:39   0:00 </code><code>grep</code> <code>nginx</code>

解决办法:

nginx换用git git正常.说明权限问题.但是服务器必须用www用户运行nginx.

解决思路:将nginx运行用户www加入git组

然后赋予git用户组可实行权限

<code>usermod</code> <code>-a -G git www</code>

<code>[root@xxx_61 home]</code><code># id www</code>

<code>uid=501(www) gid=501(www) </code><code>groups</code><code>=501(www),503(git)</code>

<code>chmod</code> <code>g+rx </code><code>/home/git/</code>

本文转自 yawei555 51CTO博客,原文链接:http://blog.51cto.com/huwei555/1739923,如需转载请自行联系原作者

继续阅读