大佬教程收集整理的这篇文章主要介绍了CentOS6安装gitlab,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
1、安装和配置必须的依赖
sudo yum install curl openssh-server openssh-clients postfix cronie sudo service postfix start sudo chkconfig postfix on sudo lokkit -s http -s ssh@H_874_21@如果运行上面的命令,发现没有安装 lokkit,那么需要你手动 yum install lokkit
2、添加和安装依赖包
lokkit 可以帮助我们设定 iptables 打开 http 和 ssh
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash sudo yum install gitlab-ce@H_874_21@ 这个依赖包有点大,建议用下载工具下载,然后用本地安装sudo yum localinstall3、配置和启动gitlab
sudo gitlab-ctl reconfigure@H_874_21@ 到这里gitlab就可以正常运行了,如果要自定访问ip或者域名的话,可以修改配置文件vi /etc/gitlab/gitlab.rb@H_874_21@ 打开后有一行 external_url 的設定改成要對外開放 web 的 url ,
例如我可以指定 git.yijiebuyi.com
只想內部使用也可以改成 http://192.168.0.11 这样的内部IP地址.
停止gitlab
gitlab-ctl stop@H_874_21@ 启动gitlabgitlab-ctl start@H_874_21@ GitLab 默认存放目录到 /var/opt/gitlab
如果要移动,备份此目录,比较保险的做法是,先停止 GitLab,然后备份目录,最后在重启GitLab
通过gitlab官方源安装好gitlab之后,程序包中会自带一个Nginx服务器,gitlab本身消耗系统资源严重,理论上最好单独部署在一台服务器上,但是为了节约成本,也会跟其他服务共用服务器,如果之前机器上就有Nginx服务则会冲突,可以修改配置,使用已经存在的Nginx。
修改gitlab使用现有Nginx服务
1 2 3 4 5 6 7 8 9 @H_874_21@ |
# vim /etc/gitlab/gitlab.rb 在配置文件中搜索 /# Nginx # Nginx['enable'] = true # Nginx['client_max_body_size'] = '250m' # Nginx['redirect_http_to_https'] = false 修改上面配置为false Nginx['enable'] = false @H_874_21@ |
将gitlab生成的Nginx配置复制到Nginx虚拟主机配置文件夹下
1 2 3 4 5 6 7 @H_874_21@ |
拷贝配置: # cp /var/opt/gitlab/Nginx/conf/gitlab-http.conf /etc/Nginx/conf.d/ 检测配置: # Nginx -t Nginx: [emerg] unkNown log format "gitlab_access" in /etc/Nginx/conf.d/gitlab-http.conf:56 Nginx: configuration file /etc/Nginx/Nginx.conf test Failed @H_874_21@ |
将配置中第13行结尾的gitlab_access去掉,即可完成验证。重启Nginx使配置生效。
权限问题
1 2 3 @H_874_21@ |
# tail -f /var/log/gitlab/Nginx/error.log 2015/11/03 15:45:10 [error] 8931#0: *15 connect() to unix:/var/opt/gitlab/gitlab-rails/sockets/gitlab.socketFailed (13: Permission denied) while connecTing to upstream,client: xxx.xxx.xxx.xx,server: git.xxxx.com,request: "GET / http/1.1",upstream: "http://unix:/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket:/",host: "git.xxxx.com" @H_874_21@ |
通过Nginx日志可以看出,Nginx没有访问gitlab的socket权限,修改方式有多种,我的机器上Nginx的执行用户是Nginx,而socket文件夹为
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 @H_874_21@ |
drwxr-x--- 2 git gitlab-www 4096 11月 3 15:57 sockets 文件赋权限 # chmod -R o+x /var/opt/gitlab/gitlab-rails/sockets or # chmod 755 /var/opt/gitlab/gitlab-rails/sockets 将Nginx用户加入gitlab-www组 # usermod -a -G gitlab-www Nginx 修改配置 # vim /etc/gitlab/gitlab.rb web_server['external_users'] = ['Nginx'] # web_server['username'] = 'gitlab-www' # web_server['group'] = 'gitlab-www' @H_874_21@ |
gitlab程序未启动的问题
1 @H_874_21@ |
2015/11/03 15:41:02 [error] 8931#0: *8 connect() to unix:/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket Failed (111: Connection refused) while connecTing to upstream,client: 111.161.77.240,server: git.yuzhewo.com,host: "git.yuzhewo.com" @H_874_21@ |
报错信息为(111: Connection refused)
cat /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket 内容为空 @H_874_21@ |
[2015-11-03T16:12:06+00:00] ERROR: CAnnot allocate memory - fork(2)@H_874_21@ |
原因可能是系统内存不足,无法分配足够内存,导致启动失败,这种情况只能升级服务器配置来解决。
https://about.gitlab.com/downloads/#centos6
http://yijiebuyi.com/blog/49aa7d3793aeafeb77da67a4159ec1aa.html
以上是大佬教程为你收集整理的CentOS6安装gitlab全部内容,希望文章能够帮你解决CentOS6安装gitlab所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。