温馨提示×

centos gitlab如何启动

小樊
38
2026-08-03 16:17:34
栏目: 智能运维

CentOS 上启动 GitLab,一般分两种情况(取决于安装方式)。下面以 最常见、官方推荐的方式(Omnibus 安装) 为准说明。


一、使用 Omnibus 方式安装的 GitLab(最常见)

1️⃣ 启动 GitLab 服务

sudo gitlab-ctl start

2️⃣ 查看运行状态

sudo gitlab-ctl status

正常会看到类似输出:

run: gitaly: (pid 1234) 10s; run: log: (pid 1233) 20s
run: nginx: (pid 1240) 10s; run: log: (pid 1239) 20s
run: postgresql: (pid 1245) 10s; run: log: (pid 1244) 20s
...

3️⃣ 如果 GitLab 没启动,重新配置并启动

sudo gitlab-ctl reconfigure
sudo gitlab-ctl start

⚠️ gitlab-ctl reconfigure 会重新生成配置文件,首次安装或改配置后一定要执行


二、设置开机自启(推荐)

sudo systemctl enable gitlab-runsvdir

查看是否启用:

systemctl is-enabled gitlab-runsvdir

三、重启 / 停止 GitLab

# 重启
sudo gitlab-ctl restart

# 停止
sudo gitlab-ctl stop

四、访问 GitLab

默认访问地址:

http://服务器IP

或你在 /etc/gitlab/gitlab.rb 中配置的域名:

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

如果改了 external_url,记得执行:

sudo gitlab-ctl reconfigure

五、常见问题排查

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

查看端口:

ss -lntp

修改端口(例如改为 8081):

external_url 'http://服务器IP:8081'

然后:

sudo gitlab-ctl reconfigure

2️⃣ 查看日志

sudo gitlab-ctl tail

只看 nginx:

sudo gitlab-ctl tail nginx

3️⃣ 防火墙放行(CentOS 7/8)

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

六、确认安装方式(如果你不确定)

rpm -qa | grep gitlab

如果看到类似:

gitlab-ee-xx.x.x
gitlab-ce-xx.x.x

✅ 就是 Omnibus 安装方式


如果你愿意,可以把以下信息发我,我可以更精确帮你排查:

  • CentOS 版本(cat /etc/centos-release
  • GitLab 版本
  • 报错信息或 gitlab-ctl status 输出

0