架构:源码安装, 数据库用mysql,网站用nginx
坑一.nginx报错
2016/07/19 09:26:11 [crit] 3881#0: *10 connect() to unix:/home/git/gitlab/tmp/sockets/gitlab-workhorse.socket failed (13: Permission denied) while connecting to upstream, client: 192.168.1.180, server: www.gitlab810.com, request: "GET / HTTP/1.1", upstream: "http://unix:/home/git/gitlab/tmp/sockets/gitlab-workhorse.socket:/", host: "www.gitlab810.com" 2016/07/19 09:26:11 [error] 3881#0: *10 open() "/home/git/gitlab/public/502.html" failed (13: Permission denied), client: 192.168.1.180, server: www.gitlab810.com, request: "GET / HTTP/1.1", upstream: "http://unix:/home/git/gitlab/tmp/sockets/gitlab-workhorse.socket/", host: "www.gitlab810.com"
这是因为我的nginx使用的是www用户运行,而/home/git/gitlab/tmp/sockets/gitlab-workhorse.socket/用户组是git,
解决方案:把git加入www用户组,并赋予实行权限
usermod -a -G git www chmod g+rx /home/git/
坑二:nginx配置不准确
[root@gitlaba git]# cat /usr/local/nginx/conf/vhosts.d/gitlab.conf |grep -v '#' upstream gitlab-workhorse { server unix:/home/git/gitlab/tmp/sockets/gitlab-workhorse.socket fail_timeout=0; } server { listen 80 ; server_name www.gitlab810.com; server_tokens off; access_log logs/gitlab_access.log; error_log logs/gitlab_error.log; location / { client_max_body_size 0; gzip off; proxy_read_timeout 300; proxy_connect_timeout 300; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Host ""; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://gitlab-workhorse; } error_page 404 /404.html; error_page 422 /422.html; error_page 500 /500.html; error_page 502 /502.html; error_page 503 /503.html; location ~ ^/(404|422|500|502|503)\.html$ { root /home/git/gitlab/public; internal; } }
注意第55行:proxy_set_header Host $http_host; 要修改成自己的server_name
坑三:
[root@gitlaba git]# vim /home/git/gitlab-shell/config.yml --- user: git gitlab_url: "http://www.gitlab810.com/" http_settings: self_signed_cert: false auth_file: "/home/git/.ssh/authorized_keys" redis: bin: /usr/local/redis/redis-cli namespace: resque:gitlab host: 127.0.0.1 port: 6379 log_level: INFO audit_usernames: false
gitlab_url: "http://www.gitlab810.com/" 这一项得用标准格式,我使用www.gitlab810.com的形式就报错