1 前提
服务器准备:
- 阿里ECS云服务器
2 GitLab官网介绍
2.1 网址
https://about.gitlab.com/
2.2 引导
进入官网 > Resources > Install GitLab > 进入到GitLab的官方下载页面 > 找到Download a GitLab Omnibus package > 点击选择操作系统版本 > 选择CE社区版下载
本文使用的时CentOS 7.3版本
3 安装
3.1 方式一 yum源下载
1.下载必要的依赖
sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd
2.开放 http 和 https 协议的访问 (防火墙处于关闭状态时此步骤可以跳过)
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld
3.安装 postfix 用于发送邮件
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
启动postfix服务时可能会出现如下错误:
Job for postfix.service failed because the control process exited with error code. See "systemctl status postfix.service" and "journalctl -xe" for details.
解决方案见下:
修改 /etc/postfix/main.cf的设置为:
inet_protocols = ipv4
inet_interfaces = all
4 获取GitLab的yum源
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
cd /etc/yum.repos.d 查看是否下载成功
5 下载并安装rpm包
sudo EXTERNAL_URL="https://gitlab.example.com" yum install -y gitlab-ce
EXTERNAL_URL的值为服务器的域名或IP地址,例如 :服务器IP地址为 192.168.10.1,则 EXTERNAL_URL="https://192.168.10.1"
3.2 方式二 手动下载
由于yum下载GitLab rpm包时由于文件较大,耗费的时间稍长,因此也可以手动本地下载rpm包,则3.1中>4,5步操作可由下述步骤替换:
4 手动下载RPM包
https://packages.gitlab.com/gitlab/gitlab-ce
5 安装及配置
# 安装rpm包
rpm -ivh gitlab-ce-12.8.1-ce.0.el7.x86_64.rpm
# 配置EXTERNAL_URL
vim /etc/gitlab/gitlab.rb
`external_url 'http://服务器的IP地址或域名'`
# 配置gitlab
gitlab-ctl reconfigure
# 重启gitlab服务
gitlab-ctl restart
安装成功后浏览器输入服务器IP地址或域名出现如下页面代表安装成功,本次安装使用的是默认的80端口。
4 ECS服务器添加安全组
由于本次安装使用的服务器是阿里云的ECS服务器,该服务器默认公网IP无法访问,此时需要在安全组中设置安全规则。
4.1 登录阿里云控制台,找到网络和安全 > 安全组 > 配置规则 > 添加安全组规则 > 开放80端口
所有操作执行完毕之后,GitLab就安装成功了!