温馨提示×

centos装gitlab失败咋办

小樊
36
2026-09-11 19:07:06
栏目: 智能运维

CentOS 上安装 GitLab 失败 是很常见的问题,通常和 系统版本、依赖、端口、内存、源 有关。下面给你一套排查 + 解决思路,按顺序来基本能搞定。


一、先确认基本信息(很重要)

请先确认你用的是哪种环境:

cat /etc/redhat-release
uname -m
free -h

常见失败原因:

  • ❌ CentOS 6(GitLab 已不支持)
  • ❌ 内存 < 2G(官方建议至少 4G)
  • ❌ 防火墙 / SELinux 没关或端口被占

二、最常见失败原因 & 解决方法

1️⃣ CentOS 版本不支持

GitLab 官方 已停止支持 CentOS 6 / 8(已 EOL)

✅ 推荐方案:

  • CentOS 7 ✅(还能用)
  • 或改用 Rocky / AlmaLinux / Ubuntu

2️⃣ 内存不足导致卡死或失败

GitLab 很吃内存:

free -h

如果内存 < 2G:

  • 加 swap
dd if=/dev/zero of=/swap bs=1M count=4096
mkswap /swap
swapon /swap

3️⃣ 官方源访问失败(国内常见)

❌ 现象:

  • curl 超时
  • yum install gitlab-ee 卡住

✅ 使用清华镜像源(国内推荐):

vi /etc/yum.repos.d/gitlab.repo

内容:

[gitlab-ce]
name=GitLab CE
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
gpgcheck=0
enabled=1

然后:

yum makecache
yum install gitlab-ce

4️⃣ 端口被占用(80 / 443 / 8080)

GitLab 默认用:

  • 80(HTTP)
  • 443(HTTPS)
  • 8080(unicorn / puma)

检查:

netstat -tunlp | grep -E '80|443|8080'

如果有 nginx / apache:

systemctl stop nginx
systemctl disable nginx

或修改 GitLab 端口:

vi /etc/gitlab/gitlab.rb
external_url 'http://你的IP:8081'
nginx['listen_port'] = 8081

然后:

gitlab-ctl reconfigure

5️⃣ SELinux / 防火墙问题

setenforce 0
systemctl stop firewalld
systemctl disable firewalld

6️⃣ 安装后 reconfigure 失败

常见错误:

  • ruby_block
  • chef 卡住

✅ 强制重来:

gitlab-ctl stop
gitlab-ctl reconfigure

或:

gitlab-ctl cleanse
gitlab-ctl reconfigure

三、推荐「最稳」安装方式(Docker)

如果你折腾 yum 老失败,强烈建议 Docker

yum install -y docker
systemctl start docker

docker run -d \
  --name gitlab \
  -p 8080:80 \
  -p 8443:443 \
  gitlab/gitlab-ce

访问:

http://服务器IP:8080

四、你可以直接把错误粘给我

如果你愿意,把下面信息发我,我可以精准定位

  1. CentOS 版本
  2. 内存大小
  3. 安装命令
  4. 完整报错日志(重点)

例如:

yum install gitlab-ce 报错:
Error: Package: gitlab-ce-...

我可以一步一步带你修。

0