说明:本文基于 原文链接 进行整理
环境
- 阿里云主机
- centos 7.6 x86_64
- 2核cpu/4g内存
搭建步骤
-
修改yum源为阿里云源:
sudo yum install -y curl wget
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache
- 安装依赖:
sudo yum install -y policycoreutils-python openssh-server
- ssh开机自启:
sudo systemctl enable sshd
- ssh启动:
sudo systemctl start sshd
- postfix安装:
sudo yum install -y postfix
- postfix开机自启:
sudo systemctl enable postfix
- 修改postfix配置:
vim /etc/postfix/main.cf
找到,inet_interfaces = localhost
,将其改为inet_interfaces = all
,:wq
保存退出, - postfix启动:
sudo systemctl start postfix
- 添加gitlab包仓库:
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
- 安装gitlab:
sudo EXTERNAL_URL="你Gitlab服务器运行所在的公网IP地址" yum install -y gitlab-ce
- 检查gitlab运行状态:
gitlab-ctl status
,看是否所有服务都正常运行的 - 访问gitlab地址:
http://你Gitlab服务器运行所在的公网IP地址
,即可出现gitlab界面,如图:
备注
- centos 7 才支持
systemctl
命令 - 1核cpu+2g内存的服务器带不动gitlab,在安装时会报允许分配的内存不足
-
gitlab常用:
- 查看状态:
gitlab-ctl status
- 查看日志:
gitlab-ctl tail
- 配置文件:
/etc/gitlab/gitlab.rb
- 安装目录:
/opt/gitlab
- 日志目录:
/var/log/gitlab
- gitlab包安装自带的服务:
nginx/redis/postgres/ruby on rails/unicorn
- 查看状态:
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。