CentOS 7 安装 GitLab 中文版

▪ 前言

Gitlab接触了一段时间,觉得是一个很不错的开源产品(gitlab的社区版),值得我整理一篇部署教程作为记录。

安装全程选择的用户为 root

 

▪ 环境

操作系统:CentOS 7.6

 

▪ 更换阿里 YUM(个人习惯)

// 备份默认的 YUM
mv /etc/yum.repos.d /etc/yum.repos.d.backup

// 设置新的 YUM 目录
mkdir /etc/yum.repos.d

// 下载阿里 YUM 配置到该目录中
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

// 重建缓存
yum clean all
yum makecache

// 升级所有包(改变软件设置和系统设置,系统版本内核都升级)
// [不推荐] yum update -y

 

二、获取 GitLab 汉化包(要部署非汉化版,可以跳过这一块内容)

GitLab 中文社区版的项目:

v7 ~ v8.8 是由 Larry Li 发起的“GitLab 中文社区版项目”(https://gitlab.com/larryli/gitlab)

v8.9 之后,@xhang 开始继续该汉化项目(https://gitlab.com/xhang/gitlab)

获取 GitLab 汉化包:

// 安装 Git
yum install -y git

// 回到用户目录
cd ~

// 下载最新的汉化包
git clone https://gitlab.com/xhang/gitlab.git

// 如果是要下载老版本的汉化包,需要加上老版本的分支,比下载 10.0.2,可以运行下面的语句
// git clone https://gitlab.com/xhang/gitlab.git -b v10.0.2-zh

// 查看该汉化补丁的版本(v12.3.5)
cat gitlab/VERSION

 

三、部署社区版 GitLab

基础配置

// 安装 GitLab 的依赖项
yum install -y curl openssh-server openssh-clients cronie policycoreutils-python

// 安装 邮箱系统(可不装)
yum install -y postfix

// 启动 Postfix
systemctl start postfix
systemctl enable postfix

// 设置防火墙 
firewall-cmd --add-service=http --permanent
firewall-cmd --reload

获取 GitLab 的 RPM 包

查看清华开源镜像站,根据上面的 “cat gitlab/VERSION” 结果,我们需要下载 v12.3.5 的 RPM 包

// 下载包
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm

// 安装 RPM 包
rpm -i gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm

根据提示,继续执行指令配置 GitLab

gitlab-ctl reconfigure

修改配置文件 gitlab.rb

vim /etc/gitlab/gitlab.rb
// ...
external_url="http://[IP]"

// ...
nginx['listen_port'] = 9091

// ...
// unicorn 是 ruby 的HTTP SERVER
unicorn['port'] = 9092

因为修改了配置文件,故需要重新加载配置内容

gitlab-ctl reconfigure
gitlab-ctl restart

四、覆盖汉化包

停止 GitLab 服务

gitlab-ctl stop

切换到 GitLab 汉化包所在的目录(即步骤二获取的汉化版 GitLab )

cd ~/gitlab

比较汉化标签和原标签,导出 patch 用的 diff 文件到 /root 下

// 根据上面的 “cat gitlab/VERSION” 结果,版本为 12.3.5
git diff v12.3.5 v12.3.5-zh > ../12.3.5-zh.diff

回到 /root 目录

cd ~

将 12.3.5-zh.diff 作为补丁更新到 GitLab 中

yum install patch -y
patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < 12.3.5-zh.diff

启动 GitLab

gitlab-ctl start

重新配置 GitLab

gitlab-ctl reconfigure

五、设置管理员密码

网页方式:

地址:http://[IP]:9091

账号:root

命令方式:

gitlab-rails console production

irb(main):001:0>user = User.where(id: 1).first      // id为1的是超级管理员
irb(main):002:0>user.password = '[PASSWORD]'        // 密码必须至少8个字符
irb(main):003:0>user.save!                          // 如没有问题 返回true

exit                                                // 退出

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值