你这个问题比较宽泛,我先分几种最常见的 GitLab 在 Linux 上的使用场景来说明,你可以看哪一种符合你的需求:
# 更新系统
sudo apt update && sudo apt upgrade -y
# 安装依赖
sudo apt install -y curl openssh-server ca-certificates
# 添加 GitLab 源
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
# 安装 GitLab(替换成你的域名或 IP)
sudo EXTERNAL_URL="http://gitlab.example.com" apt install gitlab-ce
安装完成后:
sudo gitlab-ctl reconfigure
访问:
http://服务器IP
默认账号:
rootcat /etc/gitlab/initial_root_password
sudo yum install -y curl policycoreutils openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
sudo EXTERNAL_URL="http://gitlab.example.com" yum install gitlab-ce
sudo apt install git # Ubuntu
sudo yum install git # CentOS
git config --global user.name "你的名字"
git config --global user.email "你的邮箱"
ssh-keygen -t rsa -b 4096 -C "你的邮箱"
cat ~/.ssh/id_rsa.pub
把内容复制到: GitLab → Settings → SSH Keys
# 安装
curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh" | sudo bash
sudo apt install gitlab-runner
# 注册
sudo gitlab-runner register
需要填写:
✅ 端口冲突(80/443)
✅ 内存不足导致 502
✅ 防火墙未开放
sudo ufw allow 80
sudo ufw allow 443
1️⃣ 你是 安装 GitLab 服务 还是 使用 GitLab?
2️⃣ 用的 什么 Linux 发行版?
3️⃣ 是 服务器还是本地虚拟机?
我可以直接给你一套适合你环境的完整命令。