作者:幽鸿
摘要: 上一篇博文介绍了搭建私有的Git Server。此方式适合小型团队使用,而且项目最好比较单一。如果是人数较多的团队,工程比较多,日常的维护工作量会很大。GitHub和GitLab很好用,但GitHub只能提供Public机制的库。
上一篇博文介绍了搭建私有的Git Server。此方式适合小型团队使用,而且项目最好比较单一。如果是人数较多的团队,工程比较多,日常的维护工作量会很大。GitHub和GitLab很好用,但GitHub只能提供Public机制的库。GitLab可以提供Private机制的库,但其速度实在是太慢了。最好的方法是在团队服务器上搭建类似的服务,安全性和服务均可保障,本文介绍如何搭建GitLab服务。
操作系统:CentOS6.6
IP地址:192.168.80.6
建立git
用户。
1 2 3 4 5 6 7 8 | # useradd git # passwd git # 输入git密码 Changing password for user git. New password: BAD PASSWORD: it is WAY too short BAD PASSWORD: is too simple Retype new password: passwd: all authentication tokens updated successfully. |
---|
关闭防火墙。
1 2 | # service iptables stop # chkconfig iptables off |
---|
1 2 3 4 | # yum install curl openssh-server postfix cronie # service postfix start # chkconfig postfix on # lokkit -s http -s ssh |
---|
1 2 | # curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash # yum install gitlab-ce |
---|
整个包有300多MB,如果使用yum
无法下载,可以直接下载RPM包。
1 | # wget -c https://packages.gitlab.com/gitlab/gitlab-ce/el/6/x86_64/gitlab-ce-7.13.3-ce.1.el6.x86_64.rpm |
---|
若还是很慢,复制下载地址用下载工具下载。汪汪的网盘也提供了下载,路径为/GitLab
。
手动安装rpm包。
1 | # rpm -ivh gitlab-ce-7.13.3-ce.1.el6.x86_64.rpm |
---|
直接启动GitLab并不能正常工作,需要进行配置,其所有的配置都在配置文件/etc/gitlab/gitlab.rb
中。此文件太长,太多的注释,后期研究可以查看此文档,在此从简配置。
1 2 3 4 | # mv /etc/gitlab/gitlab.rb{,.bck} # echo external_url \'http://119.29.83.38:8081\' >> /etc/gitlab/gitlab.rb # echo gitlab_rails[\'gitlab_email_from\'] = \'576938286@qq.com\' >> /etc/gitlab/gitlab.rb # echo git_data_dir \"/home/git\" >> /etc/gitlab/gitlab.rb |
---|
解释如下:第一个命令是备份配置文件,第二个命令是配置访问IP和端口,第三个命令是发送确认邮件的邮箱(无需真实存在),第四个命令是git的数据dir。 每次修改完配置文件,都需要执行如下命令。
1 | # gitlab-ctl reconfigure |
---|
然后启动gitlab:gitlab-ctl start
查看日志的方法:gitlab-ctl tail 可以显示所有日志