在 CentOS 上安装 GitLab 失败 是很常见的问题,通常和 系统版本、依赖、端口、内存、源 有关。下面给你一套排查 + 解决思路,按顺序来基本能搞定。
请先确认你用的是哪种环境:
cat /etc/redhat-release
uname -m
free -h
常见失败原因:
GitLab 官方 已停止支持 CentOS 6 / 8(已 EOL)
✅ 推荐方案:
GitLab 很吃内存:
free -h
如果内存 < 2G:
dd if=/dev/zero of=/swap bs=1M count=4096
mkswap /swap
swapon /swap
❌ 现象:
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
GitLab 默认用:
检查:
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
setenforce 0
systemctl stop firewalld
systemctl disable firewalld
常见错误:
ruby_blockchef 卡住✅ 强制重来:
gitlab-ctl stop
gitlab-ctl reconfigure
或:
gitlab-ctl cleanse
gitlab-ctl reconfigure
如果你折腾 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
如果你愿意,把下面信息发我,我可以精准定位:
例如:
yum install gitlab-ce 报错:
Error: Package: gitlab-ce-...
我可以一步一步带你修。