Git工具我们经常在开发中使用,作为代码管理,那具体在Linux中如何安装呢?
请参考以下步骤:
1、安装必要的依赖项,配置SSH开机启动,系统防火墙中开放HTTP、HTTPS访问。
yum install -y curl policycoreutils-python openssh-server
systemctl enable sshd
systemctl start sshd
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
systemctl reload firewalld/
2、安装Postfix以发送通知电子邮件,并配置开机启动。
如果要使用其他解决方案发送电子邮件,请跳过此步骤,并在安装GitLab后配置外部SMTP服务器。
yum install –y postfix
systemctl enable postfix
systemctl start postfix
3、获取gitlab rpm包
(清华镜像站) https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
找到对应版本。(也可以使用其他镜像站)
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm
4、安装rpm包
rpm -ivh gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm
5、安装 gitlab-ce
yum install -y gitlab-ce
6、修改配置
vi /etc/gitlab/gitlab.rb
external_url 'http://服务器ip:9010'
unicorn['port'] = 9898
注意:这里踩了一个坑,必须放开这二个注释不然会打开页面会502
重启服务
user['username'] = "gitlab"
user['group'] = "gitlab"
gitlab-ctl reconfigure
gitlab-ctl restart
7、访问gitlab
访问 http://安装的服务器ip:9010
例:http://127.0.0.1:9010
8、汉化下载汉化补丁
git clone https://gitlab.com/xhang/gitlab.git
cd gitlab
9、查看全部分支版本
git branch -a
10、对比版本、生成补丁包
git diff remotes/origin/10-2-stable remotes/origin/10-2-stable-zh > /tmp/10.2.2-zh.diff
11、停止服务器
gitlab-ctl stop
12、打补丁
patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < /tmp/10.2.2-zh.dif
13、启动和重新配置
gitlab-ctl start
gitlab-ctl reconfigure
汉化完成后再次刷新页面即可