CentOS 7 部署内部使用的 Gitlab

  • 原创
  • Madman
  • /
  • /
  • 0
  • 7102 次阅读

Synopsis: GitLab 是用 Ruby 和 Go 开发的开源版本管理系统,实现一个自托管的 Git 项目仓库,可通过 Web 界面进行访问公开的或者私人项目。它拥有与 Github 类似的功能,方便团队协作开发、管理,同时还可以实现完整的 CI(持续集成)、CD(持续发布)流程

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

我的环境为 CentOS-7.5,安装 Gitlab 社区版前需要先安装相关依赖包:

# yum install -y curl policycoreutils-python openssh-server

由于使用 Gitlab 需要 HTTPSSH 服务,所以如果你的 CentOS 开启了防火墙的话,比如 Firewalld 需要如下配置:

# firewall-cmd --permanent --add-service=http
# systemctl reload firewalld

# systemctl enable sshd
# systemctl start sshd

然后,在使用 Gitlab 的过程中,它可能会发送 通知邮件(notification emails) 给你,所以还需要配置 SMTP 服务器,比如使用 Postfix 包:

# yum install -y postfix
# systemctl enable postfix
# systemctl start postfix

2. 安装 Gitlab 社区版

# curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
# yum install -y gitlab-ce

或者到 https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/ 下载 RPM 包到本地后手动安装

安装完成后,需要修改配置文件 /etc/gitlab/gitlab.rb,设置浏览器访问的 URL,因为它默认是 http://gitlab.example.com,我们可以修改为 域名 或者 服务器的 IP

# vim /etc/gitlab/gitlab.rb

修改 external_url 'http://gitlab.example.com' 为 external_url 'http://10.100.5.103'
可以加端口,比如 external_url 'http://10.100.5.103:8000'

启动 Gitlab:

# gitlab-ctl reconfigure

3. 使用

通过浏览器访问 http://10.100.5.103,首先会让你修改默认用户 root 的密码:

或者查询 root 的默认密码: grep 'Password:' /etc/gitlab/initial_root_password

然后,用 root 用户登录即可:

其它管理命令:

# 启动与停止
gitlab-ctl start
gitlab-ctl stop
gitlab-ctl restart

# 查看服务状态
gitlab-ctl status

# 实时查看日志
gitlab-ctl tail
分类: Linux
标签: Gitlab CentOS
未经允许不得转载: LIFE & SHARE - 王颜公子 » CentOS 7 部署内部使用的 Gitlab

分享

作者

作者头像

Madman

如需 Linux / Python 相关问题付费解答,请按如下方式联系我

0 条评论

暂时还没有评论.