搭建 GitLab 服务
通常来讲,商用项目都需要公司内网搭建 GitLab 来提供代码管理服务。本片记录在云服务器上搭建GitLab 服务的流程以及遇到的一些坑。
操作本篇内容,需要一定的 Linux 基础和 CentOS 7 系统。
GitLab 运行环境
更新软件包
1 | yum update -y |
sshd
安装
script 1
yum install -y curl policycoreutils-python openssh-server
启用
script 1
systemctl enable sshd
启动
script 1
systemctl start sshd
配置防火墙
- 增加配置项 hexo
在 /etc/sysctl.conf
文件中末尾添加一行:
1 | net.ipv4.ip_forward = 1 |
- 增加 HTTP 方案
1 | firewall-cmd --permanent --add-service=http |
- 重启防火墙
script 1
systemctl reload firewalld
安装 GitLab
- 使用清华镜像源
出于网络环境,考虑使用清华的镜像源,在 /etc/yum.repos.d
创建 gitlab-ce.repo 文件并保存。
1 | [gitlab-ce] |
更新 yum 缓存,更新缓存文件。
1 | yum makecache |
- 安装 GitLab
1 | yum install -y gitlab-ce |
- 初始化 GitLab
1 | sudo gitlab-ctl reconfigure |
达到这一步,基本的 GitLab 服务就可用了。
配置 GitLab 域名
编辑 /etc/gitlab/gitlab.rb
文件,增加以下域名解析配置。
1 | external_url "http://gitlab.example.com" |
增加后,运行以下命令生效配置。
1 | sudo gitlab-ctl reconfigure |
配置 GitLab 邮箱 SMTP 协议
1 | gitlab_rails['smtp_enable'] = true |
相关链接
http://s0docs0gitlab0com.icopy.site/omnibus/settings/configuration.html