温馨提示×

gitlab linux怎么启动

小樊
44
2026-09-22 18:27:50
栏目: 智能运维

在 Linux 上“启动 GitLab”通常有两种常见场景,下面分别说明:


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

如果你是通过官方 .rpm 或 .deb 包安装的 GitLab(推荐方式):

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)

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

二、使用 Docker 启动 GitLab

1. 启动 GitLab 容器

sudo 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. 访问 GitLab

浏览器打开:

http://服务器IP

三、首次访问说明

  • 默认管理员账号:root
  • 初始密码(Omnibus):
sudo cat /etc/gitlab/initial_root_password

(Docker 同理,在容器内路径相同)


四、常见问题

1. 端口被占用(如 80 端口)

修改配置文件:

sudo vi /etc/gitlab/gitlab.rb
external_url 'http://ip:端口'

然后:

sudo gitlab-ctl reconfigure

2. 启动很慢

GitLab 组件较多,首次启动通常需要 1–3 分钟。


如果你能告诉我:

  • 是 物理机 / 虚拟机 / Docker / Kubernetes
  • GitLab 的 安装方式

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

0 踩