在 CentOS 离线环境中安装 GitLab,核心思路是:在能联网的机器上下载好 RPM 包及其依赖,再拷贝到离线机器上安装。下面给你一套最常用、最稳妥的方案。
以 GitLab CE 为例(社区版):
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-16.11.3-ce.0.el7.x86_64.rpm
可到清华镜像查看版本:
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
yum install --downloadonly --downloaddir=./gitlab_rpms gitlab-ce-16.11.3-ce.0.el7.x86_64.rpm
如果提示找不到,可先:
yum install yum-plugin-downloadonly
tar zcvf gitlab_rpms.tar.gz gitlab_rpms
U 盘 / scp / 其他手段拷贝到离线机。
tar zxvf gitlab_rpms.tar.gz
cd gitlab_rpms
yum localinstall -y *.rpm
或(老版本):
rpm -ivh *.rpm --nodeps --force
✅ 推荐用 yum localinstall
vi /etc/gitlab/gitlab.rb
常见修改:
external_url 'http://gitlab.example.com'
或 IP:
external_url 'http://192.168.1.100'
gitlab-ctl reconfigure
⏳ 第一次会比较慢(几分钟)
gitlab-ctl start
查看状态:
gitlab-ctl status
浏览器访问:
http://服务器IP
首次登录:
rootcat /etc/gitlab/initial_root_password
external_url 'http://IP:8081'
nginx['listen_port'] = 8081
GitLab 至少需要 4G 内存
替换 RPM 源即可:
https://packages.gitlab.com/gitlab/gitlab-ee
# 联网机
yum install --downloadonly --downloaddir=./gitlab_rpms gitlab-ce-xxx.rpm
# 离线机
yum localinstall -y *.rpm
gitlab-ctl reconfigure
gitlab-ctl start
如果你愿意,我可以:
告诉我你的 CentOS 版本 & GitLab 版本需求 即可。