目录
Centos7部署gitlab
官方文档 安装及配置
https://docs.gitlab.com/omnibus/settings/README.html
一、环境准备
环境要求
#以下要求来自官方文档
https://gitlab.com/larryli/gitlab
Ubuntu/Debian/CentOS/RHEL
Ruby (MRI) 2.1
Git 2.7.4+
Redis 2.8+
MySQL or PostgreSQL
二、安装
#下载rpm包
wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ee/packages/el/7/gitlab-ee-13.9.7-ee.0.el7.x86_64.rpm/download.rpm
#安装
yum install -y gitlab-ee-13.9.7-ee.0.el7.x86_64.rpm
#修改配置文件
vim /etc/gitlab/gitlab.rb
... ...
external_url 'http://192.168.1.246'
... ...
#刷新配置(默认启动)
gitlab-ctl reconfigure
三、gitlab邮箱设置
官方各个邮箱配置方式(https://docs.gitlab.com/omnibus/settings/smtp.html)
1、修改gitlab的配置文件
[root@test-gitlab gitlab]# vim gitlab.rb
2、按照需求配置邮箱设置
#此处实验以qq邮箱为例
... ...
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = "此处为邮箱的密码/密钥/授权码"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = '[email protected]'
gitlab_rails['smtp_domain'] = "smtp.qq.com"
... ...
3、重新载入配置
[root@test-gitlab gitlab]# gitlab-ctl reconfigure
4、进入gitlab控制台,测试发送邮件
[root@test-gitlab gitlab]# gitlab-rails console
--------------------------------------------------------------------------------
Ruby: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
GitLab: 13.7.1 (c97c8073a0e) FOSS
GitLab Shell: 13.14.0
PostgreSQL: 12.4
--------------------------------------------------------------------------------
Loading production environment (Rails 6.0.3.3)
irb(main):001:0> Notify.test_email('[email protected]', '测试邮件', '博主帅的一批').deliver_now
Notify#test_email: processed outbound mail in 6.4ms
Delivered mail [email protected] (6148.0ms)
Date: Thu, 03 Jun 2021 11:04:06 +0800
From: GitLab <[email protected]>
Reply-To: GitLab <[email protected]>
To: [email protected]
Message-ID: <[email protected]>
Subject: =?UTF-8?Q?=E6=B5=8B=E8=AF=95=E9=82=AE=E4=BB=B6?=
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Auto-Submitted: auto-generated
X-Auto-Response-Suppress: All
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body><p>杜振弘帅的一批</p></body></html>
=> #<Mail::Message:199320, Multipart: false, Headers: <Date: Thu, 03 Jun 2021 11:04:06 +0800>, <From: GitLab <[email protected]>>, <Reply-To: GitLab <[email protected]>>, <To: [email protected]>, <Message-ID: <[email protected]>>, <Subject: 测试邮件>, <Mime-Version: 1.0>, <Content-Type: text/html; charset=UTF-8>, <Content-Transfer-Encoding: 7bit>, <Auto-Submitted: auto-generated>, <X-Auto-Response-Suppress: All>>
#使用阿里企业邮箱,修改上诉配置相应参数即可,如下所示
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.mxhichina.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = "#PZGBp*4U18u"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = '[email protected]'
gitlab_rails['smtp_domain'] = "smtp.mxhichina.com"
四、修改数据默认存储位置
1、默认存储位置
#rpm包安装的gitlab,默认代码存储位置为:
/var/opt/gitlab/git-data/repositories
2、修改与数据迁移
1、创建新的数据目录
mkdir -p /data/gitlab/git-data
chown -R git.git /data/gitlab/
2、防止有新的写入数据,停用gitlab服务
gitlab-ctl stop
3、修改gitlab配置文件中的默认存放位置
vim /etc/gitlab/gitlab.rb
... ...
git_data_dirs({
"default" => {
"path" => "/data/gitlab/git-data"
}
})
... ...
4、将原有的数据迁移到新的目录
rsync -av /var/opt/gitlab/git-data/repositories/ /data/gitlab/git-data/
5、刷新gitlab配置,重启gitlab
gitlab-ctl reconfigure
gitlab-ctl start