在 CentOS(7/8/Stream) 上快速部署 GitLab,最推荐、最省事的方式是使用 GitLab 官方 Omnibus 包。下面是生产可用、步骤最少的完整方案。
setenforce 0
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
yum install -y curl policycoreutils openssh-server openssh-clients
systemctl enable sshd
systemctl start sshd
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | bash
如果你只需要 CE(社区版),把
gitlab-ee换成gitlab-ce
EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ee
EXTERNAL_URL="http://你的服务器IP" yum install -y gitlab-ee
安装过程约 3–10 分钟
gitlab-ctl reconfigure
✅ 成功后你会看到类似:
gitlab Reconfigured!
浏览器访问:
http://服务器IP
rootcat /etc/gitlab/initial_root_password
⚠️ 密码只显示一次,建议立即修改
gitlab-ctl status # 查看状态
gitlab-ctl restart # 重启
gitlab-ctl stop # 停止
gitlab-ctl tail # 查看日志
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload
vim /etc/gitlab/gitlab.rb
常见修改:
external_url 'http://gitlab.example.com'
gitlab_rails['time_zone'] = 'Asia/Shanghai'
修改后执行:
gitlab-ctl reconfigure
sidekiq['max_concurrency'] = 10
puma['worker_processes'] = 2
puma['min_threads'] = 1
puma['max_threads'] = 2
如果官方源慢,可切换为清华源:
vim /etc/yum.repos.d/gitlab_gitlab-ee.repo
替换为:
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ee/
| 场景 | 推荐 |
|---|---|
| 企业/生产 | GitLab EE |
| 个人/学习 | GitLab CE |
| 内网 | 关闭 HTTPS,使用 HTTP |
yum install -y curl
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | bash
EXTERNAL_URL="http://$(hostname -I | awk '{print $1}')" yum install -y gitlab-ee
gitlab-ctl reconfigure
如果你需要:
告诉我你的 CentOS 版本 + 使用场景,我可以给你定制方案。