温馨提示×

gitlab在linux如何启动

小樊
42
2026-09-13 14:14:34
栏目: 智能运维

在 Linux 上启动 GitLab 取决于你的安装方式,常见情况如下:


一、使用 Omnibus 包安装(最常见)

1. 启动 GitLab

sudo gitlab-ctl start

2. 停止 GitLab

sudo gitlab-ctl stop

3. 重启 GitLab

sudo gitlab-ctl restart

4. 查看运行状态

sudo gitlab-ctl status

5. 开机自启(systemd)

Omnibus 安装默认会注册 systemd 服务,一般无需手动设置:

sudo systemctl enable gitlab-runsvdir.service
sudo systemctl start gitlab-runsvdir.service

二、使用 Docker 安装

1. 启动容器

docker start gitlab

(假设容器名为 gitlab

2. 首次运行(示例)

docker run --detach \
  --hostname gitlab.example.com \
  --publish 443:443 --publish 80:80 --publish 22:22 \
  --name gitlab \
  --restart always \
  gitlab/gitlab-ee:latest

3. 查看日志

docker logs -f gitlab

三、从源码安装(不推荐新手)

sudo service gitlab start
# 或
sudo /etc/init.d/gitlab start

或使用 systemd:

sudo systemctl start gitlab

四、启动后访问

  • 浏览器访问:
    http://服务器IP
    
  • 默认管理员:
    • 用户名:root
    • 密码在:
      sudo cat /etc/gitlab/initial_root_password
      

五、常见问题

1. 端口被占用

修改配置:

sudo vim /etc/gitlab/gitlab.rb
external_url 'http://IP:端口'

然后:

sudo gitlab-ctl reconfigure

2. 启动很慢

GitLab 组件多,首次启动可能需 1–3 分钟。


如果你能告诉我:

  • Omnibus / Docker / 源码
  • 使用的 Linux 发行版(Ubuntu / CentOS / Rocky 等)

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

0