一、目标环境
Ubuntu 24.04,拟安装社区版gitlab。无废话流程。

二、安装步骤
1. 前置步骤
启用ssh
sudo systemctl enable --now ssh
防火墙放行
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
安装curl
sudo apt install -y curl
添加仓库包
curl "https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh" | sudo bash
2. 安装gitlab-ce
sudo EXTERNAL_URL="https://gitlab.example.com" apt install gitlab-ce
3. 部署安装完成后
1)重置root密码
[root@test bin]# gitlab-rails console
irb(main):001:0> user = User.where(id:1).first
irb(main):002:0> user.password = ‘修改的密码(必须超过八位)’
irb(main):004:0> user.save
irb(main):005:0> exit
2)编辑配置文件,设置为你的url
vim /etc/gitlab/gitlab.rb
external_url ‘http://172.16.237.141’
三、可能会碰到的问题
报错:there was a problem with public attribute
问题日志
There was an error running gitlab-ctl reconfigure:
Cookbook gitlab-ee not found. If you're loading gitlab-ee from another cookbook, make sure you configure the dependency in your metadata
Running handlers complete
[2025-09-02T18:51:23+08:00] ERROR: Exception handlers complete
问题分析
这个错误表明系统中仍然残留着 GitLab EE(企业版)的配置信息,导致在配置 GitLab CE(社区版)时出现冲突。可以按照以下步骤彻底清理残留配置并重新安装
彻底彻底卸载残留的 GitLab 组件:
# 停止所有 GitLab 服务
sudo gitlab-ctl stop
# 卸载 GitLab 包(保留配置文件)
sudo apt-get remove gitlab-ce gitlab-ee
# 彻底清除所有配置和数据(谨慎操作,这会删除所有数据)
sudo apt-get purge gitlab-ce gitlab-ee
# 删除残留文件和目录
sudo rm -rf /etc/gitlab
sudo rm -rf /var/opt/gitlab
sudo rm -rf /var/log/gitlab
清理系统缓存并重新安装 GitLab CE:
# 清理 apt 缓存
sudo apt-get autoremove
sudo apt-get clean
# 重新安装 GitLab CE(请替换为最新版本的下载链接)
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo apt-get install gitlab-ce
重新配置 GitLab CE:
sudo gitlab-ctl reconfigure
这些步骤会彻底清除之前 GitLab EE 的残留配置,确保 GitLab CE 能够干净地安装和配置。如果问题仍然存在,可能需要检查 /etc/gitlab 目录是否还有残留的配置文件,并手动删除它们。