Skip to content

基于CentOS7安装GitLab私有仓库

约 341 字大约 1 分钟

CentOS7GitLab

2025-09-29

1、linux安装gitlab

# 使用centos7是因为版本稳定、依赖软件源好.
# 部署环境: centos7 2核4G 40G | gitlab 17.6.5
# 替换下载源为阿里下载源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
yum install vim -y

# 防火墙配置
systemctl status firewalld
systemctl stop firewalld
systemctl start firewalld
systemctl restart firewalld
systemctl disable firewalld
systemctl enable firewalld

# cd /gitlab 安装
rpm -Uvh gitlab-ce-17.6.5-ce.0.el7.x86_64.rpm --force --nodeps
# 配置域名或IP(reconfigure刷新配置)
external_url 'http://192.168.184.128'
gitlab-ctl reconfigure
# 启动服务并打印初始化密码
gitlab-ctl start
cat /etc/gitlab/initial_root_password
8Ne+Fk3QgziRJOpbFkCULxTdtHTjyoxkjCsnmqB4PkM=
# 访问并修改密码(初始化密码24小时有效) => 头像->Edit Profile->Password->修改
http://192.168.184.128/
root\zhangjian55575@
# 添加用户
zhangjian\Your55575@
# 设置中文界面 => 头像->Preferences->Localization->Chinese, Simplified - 简体中文 (94% translated)->重新登录

# 备份与恢复(https://archives.docs.gitlab.com/17.7/ee/administration/backup_restore/)
# 备份
gitlab-backup create
# 进入目录查看本份文件
/var/opt/gitlab/backups
# 恢复(恢复备份不需要加文件名后缀_gitlab_backup.tar)、停止puma、sidekiq服务、恢复后重新启动服务
gitlab-ctl stop puma
gitlab-ctl stop sidekiq
gitlab-ctl status
gitlab-backup restore BACKUP=1741452022_2025_03_08_17.6.5
gitlab-ctl restart

# 后续邮件配置看官方文档

# 基本操作
gitlab-ctl status
gitlab-ctl start
gitlab-ctl stop
gitlab-ctl restart

2、Frp管理

# 查看Frp配置文档