下面分两种常见场景说明 GitLab 在 Debian 系统上的适配方式:
✅ 推荐用 Omnibus 官方包(最简单、最稳定)
⚠️ 不推荐在 Debian 上手动编译或直接用源码部署
GitLab 官方明确支持特定 Debian 版本,不同 GitLab 版本对应不同 Debian:
| GitLab 版本 | 推荐 Debian |
|---|---|
| GitLab CE / EE 16.x | Debian 11 (Bullseye) |
| GitLab CE / EE 17.x | Debian 12 (Bookworm) |
| 旧版本 | Debian 10(已逐步淘汰) |
✅ 强烈建议
testing / sid查看系统版本:
lsb_release -a
# 或
cat /etc/debian_version
sudo apt update
sudo apt install -y curl openssh-server ca-certificates tzdata
如果需要邮件功能:
sudo apt install -y postfix
(选择 Internet Site 即可)
curl -fsSL https://packages.gitlab.com/gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/gitlab-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/gitlab-archive-keyring.gpg] \
https://packages.gitlab.com/gitlab/gitlab-ce/debian $(lsb_release -cs) main" \
| sudo tee /etc/apt/sources.list.d/gitlab_gitlab-ce.list
sudo apt update
sudo apt install -y gitlab-ce
安装完成后会看到 GitLab 的 ASCII 图标和提示
编辑配置文件:
sudo editor /etc/gitlab/gitlab.rb
最少需要设置:
external_url 'http://gitlab.example.com'
如果是 IP 访问:
external_url 'http://192.168.1.100'
然后执行:
sudo gitlab-ctl reconfigure
⏳ 首次配置大约需要 2–5 分钟
浏览器访问:
http://服务器IP
首次登录:
rootsudo cat /etc/gitlab/initial_root_password
sudo ufw allow 80
sudo ufw allow 443
sudo ufw reload
| 使用规模 | 内存 |
|---|---|
| 测试 / 个人 | 4 GB |
| 小团队 | 8 GB |
| 生产环境 | ≥ 16 GB |
⚠️ 1–2 GB 内存会导致 GitLab 频繁 500 错误
sudo gitlab-ctl status
sudo gitlab-ctl restart
sudo gitlab-ctl tail
如果你更熟悉 Docker:
docker run -d \
--hostname gitlab.example.com \
-p 80:80 -p 443:443 -p 22:22 \
--name gitlab \
-v gitlab-config:/etc/gitlab \
-v gitlab-logs:/var/log/gitlab \
-v gitlab-data:/var/opt/gitlab \
gitlab/gitlab-ce:latest
适合:
原因:Debian 版本过旧或代号为空
解决:
lsb_release -cs
确认是否为 bullseye / bookworm
原因:内存不足或 reconfigure 未完成
解决:
sudo gitlab-ctl reconfigure
free -h
✅ Debian 最佳适配方案
如果你愿意,可以告诉我:
我可以给你一套完全贴合你环境的 GitLab 部署方案。