1. 安装并配置必要的依赖关系

在CentOS 7上,下面的命令也会打开系统防火墙中的HTTP和SSH访问。

[root@iZ2zeaueqbt7jp1e182ixv ~]# yum install -y curl wget policycoreutils-python openssh-server openssh-clients git
[root@iZ2zeaueqbt7jp1e182ixv ~]# systemctl enable sshd
[root@iZ2zeaueqbt7jp1e182ixv ~]# systemctl start sshd
[root@iZ2zeaueqbt7jp1e182ixv ~]# firewall-cmd --permanent --add-service=http
[root@iZ2zeaueqbt7jp1e182ixv ~]# systemctl reload firewalld

安装Postfix发送通知邮件。如果您想使用其他解决方案发送电子邮件,请跳过此步骤并在安装GitLab后配置外部SMTP服务器。

[root@iZ2zeaueqbt7jp1e182ixv ~]# yum install -y postfix
[root@iZ2zeaueqbt7jp1e182ixv ~]# systemctl enable postfix
[root@iZ2zeaueqbt7jp1e182ixv ~]# systemctl start postfix

2. 添加GitLab软件包储存库并安装软件包

添加GitLab软件包库

[root@iZ2zeaueqbt7jp1e182ixv ~]# curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | bash

接下来,安装GitLab软件包。 将http://gitlab.example.com更改为您要访问您的GitLab实例的URL。 安装将自动配置并启动该URL的GitLab。

[root@iZ2zeaueqbt7jp1e182ixv ~]#  EXTERNAL_URL="http://gitlab.example.com" yum -y install gitlab-ee  #默认安装的是Gitlab最新版本,若觉得这里下载比较慢或需要安装旧版本可以到[清华大学开源网站镜像站](https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/)下载rpm包安装
[root@iZ2zeaueqbt7jp1e182ixv ~]#  gitlab-ctl reconfigure

Gitlab 常用命令:

# gitlab-ctl status   查看GitLab的运行状态
# gitlab-ctl restart   重新启动
# gitlab-ctl tail unicorn  查看unicorn日志; 按 Ctrl-C 退出
# gitlab-ctl tail gitlab-rails 拉取/var/log/gitlab下子目录的日志
# gitlab-ctl tail nginx/gitlab_error.log  拉取某个指定的日志
# gitlab-ctl tail 查看所有的logs; 按 Ctrl-C 退出

3.访问主机名或者IP地址登录

在第一次访问时,您将被重定向到密码重置界面。 提供初始管理员帐户的密码,您将被重定向回登陆界面使用默认帐户的用户名root登录。

4.下载Gitlab汉化版本库汉化

下载汉化版本库之前先检查系统已经安装的Gitlab版本号,确保与克隆获取的版本库版本号一致。

[root@iZ2zeaueqbt7jp1e182ixv ~]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION  //查看系统已经安装的Gitlab版本号
10.3.2-ee
[root@iZ2zeaueqbt7jp1e182ixv ~]# git clone https://gitlab.com/xhang/gitlab.git   //克隆获取汉化版本库,默认是获取最新的。如果需要下载老版本的汉化包,则要加上老版本的分支,如:git clone https://gitlab.com/xhang/gitlab.git -b v10.2.5-zh
[root@iZ2zeaueqbt7jp1e182ixv ~]# gitlab-ctl stop
[root@iZ2zeaueqbt7jp1e182ixv ~]# cd gitlab/
[root@iZ2zeaueqbt7jp1e182ixv gitlab]# git fetch
[root@iZ2zeaueqbt7jp1e182ixv gitlab]# git diff v10.3.2 v10.3.2-zh > ../10.3.2-zh.diff
[root@iZ2zeaueqbt7jp1e182ixv gitlab]# cd ..
[root@iZ2zeaueqbt7jp1e182ixv ~]# patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < 10.3.2-zh.diff
[root@iZ2zeaueqbt7jp1e182ixv ~]# gitlab-ctl start

以下是汉化后的登陆界面