gitlab官方安装方法,如下链接。因国内网络限制,本文修改部分内容。因源码安装太折磨人,故使用官网的Omnibus安装包安装。
1
2
3
4
|
# Centos7
https:
//www
.gitlab.cc
/installation/
#centos-7
# Centos6
https:
//www
.gitlab.cc
/installation/
#centos-6
|
1. 安装并配置必要的依赖关系
如果你想使用 Postfix 发送邮件,请在安装过程中根据提示选择 'Internet Site'。 你也可以用 Sendmail 或者 配置一个自定义的 SMTP 服务 并 把它作为一个 SMTP 服务器。
在 CentOS 系统上,下面的命令将会打开系统防火墙 HTTP 和 SSH 的访问
1
2
|
sudo
yum
install
curl openssh-server openssh-clients cronie
sudo
lokkit -s http -s
ssh
|
2. 添加 GitLab 镜像源并安装
新建 /etc/yum.repos.d/gitlab-ce.repo
,内容为
1
2
3
4
5
|
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https:
//mirrors
.tuna.tsinghua.edu.cn
/gitlab-ce/yum/el
$releasever/
gpgcheck=0
enabled=1
|
再执行
1
2
|
sudo
yum makecache
sudo
yum
install
gitlab-ce
|
3. 配置并启动 GitLab
1
2
3
4
5
6
|
# 配置external_url变量的地址修改为gitlab所在centos的ip地址
vim
/etc/gitlab/gitlab
.rb
# 修改变量
external_url
'http://192.168.80.128'
# 重新加载配置文件
sudo
gitlab-ctl reconfigure
|
4. 通过浏览器访问上一步配置的域名
第一次访问 GitLab,系统会重定向 url 到重置密码的页面,你需要输入初始化管理员账号的密码。 设置完成后,系统会重定向到登录界面,你就可以使用刚才输入的密码登录系统了。
系统默认的管理员账号为 root, 登录系统后,你可以修改管理员账号为自己喜欢的账号。
5. 汉化
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# 5.1 查看gitlab版本
cat
/opt/gitlab/embedded/service/gitlab-rails/VERSION
# 5.2 下载git
yum
install
-y git
# 5.3 直接克隆代码,注意V8.9之前由larryli汉化项目
git clone
# 5.4 V8.9之后由xhang汉化项目
git clone
# 5.5 查看克隆的版本与gitlab是否相同
cat
gitlab
/VERSION
# 如果已经克隆过,则进行更新(第一次部署不用更新)
git fetch
# 5.6 复制一个和源目录一样的目录,后面多一个.ori
cp
-r
/opt/gitlab/embedded/service/gitlab-rails
{,.ori}
# 5.7 将gitlab服务停止
gitlab-ctl stop
# 5.8 切换到gitlab汉化包所在的目录(即步骤二获取的汉化版gitlab
cd
/root/gitlab
# 5.9.1 比较汉化标签和原标签,导出 patch 用的 diff 文件到/root下
git
diff
v10.1.1 v10.1.1-zh > ..
/10
.1.1-zh.
diff
# 5.9.2 将10.1.1-zh.diff作为补丁更新到gitlab中
patch -d
/opt/gitlab/embedded/service/gitlab-rails
-p1 <
/root/10
.1.1-zh.
diff
# 5.9.3 启动gitlab并重新加载配置
gitlab-ctl start
gitlab-ctl reconfigure
|
6. Gitlab配置163邮箱
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# 6.1 编辑Gitlab配置文件gitlab.rb
vim
/etc/gitlab/girlab
.rb
gitlab_rails[
'gitlab_email_from'
] =
'user1@163.com'
gitlab_rails[
'smtp_enable'
] =
true
gitlab_rails[
'smtp_address'
] =
"smtp.163.com"
gitlab_rails[
'smtp_port'
] = 465
gitlab_rails[
'smtp_user_name'
] =
"user1@163.com"
gitlab_rails[
'smtp_password'
] =
"password"
gitlab_rails[
'smtp_domain'
] =
"smtp.163.com"
gitlab_rails[
'smtp_authentication'
] =
"login"
gitlab_rails[
'smtp_enable_starttls_auto'
] =
true
gitlab_rails[
'smtp_tls'
] =
true
gitlab_rails[
'gitlab_email_from'
] =
'jingdongcaiyu@163.com'
# 6.2 重新加载配置
gitlab-ctl reconfigure
# 6.3 测试配置是否成功
gitlab-rails console
# 稍等几分钟
Notify.test_email(
'9278718999@qq.com'
,
'测试主题'
,
'测试内容'
).deliver_now
|
本文转自 运维小学生 51CTO博客,原文链接:http://blog.51cto.com/yasar/1978650,如需转载请自行联系原作者