温馨提示×

gitlab如何在debian启动

小樊
36
2026-10-23 00:24:00
栏目: 智能运维

下面按常见场景给你说明:在 Debian 上“启动 GitLab”通常有两种情况——
1️⃣ 你安装的是 GitLab 官方 Omnibus 包(推荐)
2️⃣ 你是用 Docker 运行的 GitLab


一、Omnibus 方式(最常见)

1. 安装后首次启动

sudo gitlab-ctl reconfigure
sudo gitlab-ctl start

2. 查看运行状态

sudo gitlab-ctl status

3. 设置开机自启(Debian 默认已启用)

sudo systemctl enable gitlab-runsvdir

4. 启动 / 停止 / 重启

sudo gitlab-ctl start
sudo gitlab-ctl stop
sudo gitlab-ctl restart

5. 访问 GitLab

默认地址:

http://<服务器IP>

首次登录账号:

  • 用户名:root
  • 密码在:
sudo cat /etc/gitlab/initial_root_password

二、Docker 方式启动 GitLab

1. 启动容器

docker run --detach \
  --hostname gitlab.example.com \
  --publish 443:443 --publish 80:80 --publish 22:22 \
  --name gitlab \
  --restart always \
  --volume /srv/gitlab/config:/etc/gitlab \
  --volume /srv/gitlab/logs:/var/log/gitlab \
  --volume /srv/gitlab/data:/var/opt/gitlab \
  gitlab/gitlab-ee:latest

2. 查看容器状态

docker ps

3. 停止 / 启动

docker stop gitlab
docker start gitlab

三、常见问题排查

端口被占用(如 80)

修改配置:

sudo nano /etc/gitlab/gitlab.rb

示例:

external_url 'http://gitlab.example.com'
nginx['listen_port'] = 8080

然后:

sudo gitlab-ctl reconfigure

启动很慢

GitLab 组件多,首次启动可能 3–5 分钟,属正常现象。


四、确认 Debian 服务方式

systemctl status gitlab-runsvdir

如果你能告诉我:

  • ✅ 是 Omnibus 还是 Docker
  • ✅ Debian 版本(11 / 12)
  • ✅ 启动时报什么错

我可以给你更精确的命令。

0 踩