下面以 CentOS 7 / 8 为例,给你一套从零到可用的 GitLab 设置流程(社区版 GitLab CE)。如果你用的是 CentOS Stream / Rocky / Alma,步骤基本一致。
sudo yum update -y
sudo yum install -y curl policycoreutils openssh-server \
openssh-clients postfix wget
sudo systemctl enable sshd
sudo systemctl start sshd
sudo systemctl enable postfix
sudo systemctl start postfix
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
sudo EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ce
✅ 注意
EXTERNAL_URL 填你的服务器 IP 或域名EXTERNAL_URL="http://192.168.1.100"
sudo gitlab-ctl reconfigure
⏳ 这一步会比较慢,耐心等待
浏览器访问:
http://服务器IP
首次登录会要求你设置 root 密码
sudo vi /etc/gitlab/gitlab.rb
修改:
external_url 'http://your-domain.com'
然后:
sudo gitlab-ctl reconfigure
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
gitlab-ctl status # 查看状态
gitlab-ctl start # 启动
gitlab-ctl stop # 停止
gitlab-ctl restart # 重启
gitlab-ctl reconfigure # 重新应用配置
sudo setenforce 0
(生产环境建议配置规则,而不是关闭)
编辑:
sudo vi /etc/gitlab/gitlab.rb
减少 sidekiq / unicorn 进程:
puma['worker_processes'] = 2
sidekiq['max_concurrency'] = 10
✅ 配置 HTTPS(Let’s Encrypt)
✅ 使用独立数据库(PostgreSQL)
✅ 定期备份
✅ 使用域名 + Nginx 反向代理
如果你愿意,可以告诉我:
我可以帮你定制一套完整生产方案。