温馨提示×

Debian如何启动GitLab

小樊
48
2026-07-07 06:48:02
栏目: 智能运维

在 Debian 上启动 GitLab(Omnibus 安装方式),通常按下面步骤来即可。


一、确认 GitLab 是否已安装

dpkg -l | grep gitlab

或查看版本:

gitlab-rake gitlab:env:info

二、启动 GitLab(最常见方式)

GitLab Omnibus 包自带服务管理命令:

1️⃣ 启动 GitLab 所有服务

sudo gitlab-ctl start

2️⃣ 查看运行状态

sudo gitlab-ctl status

正常会看到类似:

run: gitaly: (pid 1234) 10s
run: gitlab-workhorse: (pid 1235) 10s
run: nginx: (pid 1236) 10s
run: postgresql: (pid 1237) 10s
run: redis: (pid 1238) 10s
run: sidekiq: (pid 1239) 10s
run: puma: (pid 1240) 10s

三、如果 GitLab 没有启动成功

1️⃣ 重新配置 GitLab(很重要)

修改配置后必须执行:

sudo gitlab-ctl reconfigure

2️⃣ 重启 GitLab

sudo gitlab-ctl restart

四、设置开机自启(systemd)

Omnibus GitLab 默认已配置 systemd,但可确认:

sudo systemctl enable gitlab-runsvdir

手动启动服务:

sudo systemctl start gitlab-runsvdir

查看状态:

sudo systemctl status gitlab-runsvdir

五、访问 GitLab

默认地址(如果没有修改):

http://服务器IP
或
http://localhost

首次访问会要求设置 root 密码


六、常见问题排查

1️⃣ 端口被占用(如 80 / 443)

查看端口:

sudo ss -lntp

修改 GitLab 端口:

sudo editor /etc/gitlab/gitlab.rb

示例:

external_url 'http://gitlab.example.com:8080'

然后:

sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart

2️⃣ 查看日志

sudo gitlab-ctl tail

或单独查看:

sudo gitlab-ctl tail nginx
sudo gitlab-ctl tail puma

七、非 Omnibus(Docker / 源码)方式(简要)

Docker 启动示例

docker run -d \
  --hostname gitlab.example.com \
  --publish 443:443 --publish 80:80 \
  --name gitlab \
  gitlab/gitlab-ee:latest

八、总结(最常用)

sudo gitlab-ctl reconfigure
sudo gitlab-ctl start
sudo gitlab-ctl status

如果你愿意,可以告诉我:

  • ✅ 是 物理机 / 虚拟机 / 云服务器
  • ✅ GitLab Omnibus 还是 Docker
  • ✅ Debian 版本(cat /etc/debian_version

我可以给你更精确的启动和排错方案。

0