温馨提示×

GitLab在CentOS如何启动

小樊
36
2026-08-29 20:17:44
栏目: 智能运维

CentOS 上启动 GitLab,通常取决于你的安装方式。下面是最常见的 Omnibus GitLab 启动流程(官方推荐方式)。


一、确认 GitLab 是否已安装

gitlab-ctl status

如果能看到服务状态,说明 GitLab 已安装。


二、启动 GitLab(Omnibus 安装)

1️⃣ 启动所有 GitLab 服务

sudo gitlab-ctl start

2️⃣ 查看运行状态

sudo gitlab-ctl status

正常会看到类似:

run: gitaly: (pid 1234) 10s
run: nginx: (pid 1235) 10s
run: postgresql: (pid 1236) 10s
run: redis: (pid 1237) 10s
run: sidekiq: (pid 1238) 10s
run: unicorn / puma: (pid 1239) 10s

三、如果服务未启动或异常

重启 GitLab

sudo gitlab-ctl restart

重新加载配置

如果修改过 /etc/gitlab/gitlab.rb

sudo gitlab-ctl reconfigure

四、确认 GitLab 开机自启

GitLab 一般会使用 systemd

sudo systemctl enable gitlab-runsvdir
sudo systemctl start gitlab-runsvdir

查看状态:

systemctl status gitlab-runsvdir

五、访问 GitLab

默认访问地址:

http://服务器IP

如果是第一次启动,可能需要设置管理员密码。


六、常见问题排查

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

sudo netstat -tunlp | grep 80

修改端口(如改为 8080):

编辑 /etc/gitlab/gitlab.rb

external_url 'http://IP:8080'
nginx['listen_port'] = 8080

然后:

sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart

2️⃣ 查看日志

sudo gitlab-ctl tail

或指定服务:

sudo gitlab-ctl tail nginx

七、GitLab 常用命令速查

功能 命令
启动 gitlab-ctl start
停止 gitlab-ctl stop
重启 gitlab-ctl restart
查看状态 gitlab-ctl status
重载配置 gitlab-ctl reconfigure
查看日志 gitlab-ctl tail

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

  • ✅ GitLab 版本
  • ✅ CentOS 版本(7 / 8 / Stream)
  • ✅ 是否 Docker 安装

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

0