CentOS 7 下 GitLab安装部署教程

一、前言

1、GitLab是什么?

GitLab一个开源的git仓库管理平台,方便团队协作开发、管理。在GitLab上可以实现完整的CI(持续集成)、CD(持续发布)流程。而且还提供了免费使用的Plan,以及免费的可以独立部署的社区版本(https://gitlab.com/gitlab-org/gitlab-ce)。

官网:https://about.gitlab.com/

2、本篇环境信息

工具/环境版本
Linux ServerCentOS 7
GitLab社区版 11.1.4

二、准备工作

1、安准基础依赖

#安装技术依赖
sudo yum install -y curl policycoreutils-python openssh-server

#启动ssh服务&设置为开机启动
sudo systemctl enable sshd
sudo systemctl start sshd

2、安装Postfix

Postfix是一个邮件服务器,GitLab发送邮件需要用到

#安装postfix
sudo yum install -y postfix

#启动postfix并设置为开机启动
sudo systemctl enable postfix
sudo systemctl start postfix

3、开放ssh以及http服务(80端口)

#开放ssh、http服务
sudo firewall-cmd --add-service=ssh --permanent
sudo firewall-cmd --add-service=http --permanent

#重载防火墙规则
sudo firewall-cmd --reload

三、部署过程

本次我们部署的是社区版:gitlab-ce,如果要部署商业版可以把关键字替换为:gitlab-ee

1、Yum安装GitLab

  • 添加GitLab社区版Package
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
  • 安装GitLab社区版
sudo yum install -y gitlab-ce

安装成功后会看到gitlab-ce打印了以下图形

image

2、配置GitLab站点Url

GitLab默认的配置文件路径是/etc/gitlab/gitlab.rb

默认的站点Url配置项是:
external_url 'http://gitlab.example.com'

这里我将GitLab站点Url修改为http://git.ken.io
也可以用IP代替域名,这里根据自己需求来即可

#修改配置文件
sudo vi /etc/gitlab/gitlab.rb

#配置首页地址(大约在第15行)
external_url 'http://git.ken.io'

3、启动并访问GitLab

  • 启动GitLab
#重新配置并启动
sudo gitlab-ctl reconfigure

#完成后将会看到如下输出
Running handlers complete
Chef Client finished, 432/613 resources updated in 03 minutes 43 seconds
gitlab Reconfigured!
  • 访问GitLab

将设置的域名DNS解析到服务器IP,或者修改本地host将域名指向服务器IP。
访问:http://git.ken.io

image

这时候会提示为管理员账号设置密码。管理员账号默认username是root
设置完成之后即可使用root账号登录,登陆后会进入欢迎界面。

image

四、GitLab常用配置

1、禁用创建组权限

GitLab默认所有的注册用户都可以创建组。但对于团队来说,通常只会给Leader相关权限。
虽然可以在用户管理界面取消权限,但毕竟不方便。我们可以通过配置GitLab默认禁用创建组权限。

#修改配置文件
sudo vi /etc/gitlab/gitlab.rb

#开启gitlab_rails['gitlab_default_can_create_group'] 选项,并将值设置为false
### GitLab user privileges
gitlab_rails['gitlab_default_can_create_group'] = false

#保存后,重新配置并启动GitLab
sudo gitlab-ctl reconfigure

2、gitlab-ctl常用命令介绍

命令说明
check-config检查在gitlab中是否有任何配置。在指定版本中删除的rb
deploy-page安装部署页面
diff-config将用户配置与包可用配置进行比较
remove-accounts删除所有用户和组
upgrade升级
service-list查看所有服务
once如果GitLab服务停止了就启动服务,如果已启动就不做任何操作
restart重启GitLab服务
start如果GitLab服务停止了就启动服务,如果已启动就重启服务
stop停止GitLab服务
status查看GitLab服务状态
reconfigurereconfigure重新配置GitLab并启动

五、备注

  • 本篇参考

https://about.gitlab.com/installation/#centos-7

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值