温馨提示×

gitlab linux怎么装

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

下面给你 在 Linux 上安装 GitLab(社区版 CE) 的常见做法,分几种常见系统说明,最推荐用 官方 Omnibus 包,简单稳定。


一、准备工作

  • 一台 Linux 服务器(推荐 4G 内存以上
  • 已配置好域名(可选但推荐)
  • rootsudo 用户操作

二、Ubuntu / Debian 安装(最常用)

1. 安装依赖

sudo apt update
sudo apt install -y curl openssh-server ca-certificates tzdata perl

2. 添加 GitLab 仓库

curl -fsSL https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/setup.sh | sudo bash

3. 安装 GitLab

sudo EXTERNAL_URL="http://gitlab.example.com" apt install gitlab-ce

gitlab.example.com 改成你的域名或 IP
例如:http://192.168.1.100

4. 访问

浏览器打开:

http://你的IP或域名

首次登录账号:root
密码在:

cat /etc/gitlab/initial_root_password

三、CentOS / RHEL 安装

1. 安装依赖

sudo yum install -y curl policycoreutils openssh-server perl
sudo systemctl enable sshd
sudo systemctl start sshd

2. 添加仓库

curl -fsSL https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/setup.sh | sudo bash

3. 安装

sudo EXTERNAL_URL="http://gitlab.example.com" yum install gitlab-ce

四、常用管理命令

sudo gitlab-ctl reconfigure   # 重新加载配置
sudo gitlab-ctl restart       # 重启
sudo gitlab-ctl status        # 查看状态
sudo gitlab-ctl stop          # 停止

五、Docker 方式(简单可选)

docker run -d \
  --hostname gitlab.example.com \
  -p 80:80 -p 443:443 -p 22:22 \
  --name gitlab \
  gitlab/gitlab-ce:latest

六、常见问题

  • 卡在 502:内存不够,至少 4G
  • 想用 HTTPS:配置 EXTERNAL_URL=https://域名
  • 改端口
vi /etc/gitlab/gitlab.rb
nginx['listen_port'] = 8080

如果你告诉我:

  • 用的 什么 Linux(Ubuntu/CentOS/麒麟等)
  • 内网还是公网
  • 要不要 HTTPS / 邮件

我可以给你一份精确安装配置

0