下面给你 在 Ubuntu 上安装 GitLab(社区版 CE) 的几种常见方式和步骤,最推荐的是 官方 Omnibus 包安装,简单稳定。
sudo apt update
sudo apt upgrade -y
sudo apt install -y curl openssh-server ca-certificates tzdata perl
curl -fsSL https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/setup.sh | sudo bash
⚠️ 把 gitlab.example.com 改成你的域名或服务器 IP
sudo EXTERNAL_URL="http://gitlab.example.com" apt install gitlab-ce
如果是本地测试:
sudo EXTERNAL_URL="http://192.168.1.100" apt install gitlab-ce
浏览器打开:
http://你的IP或域名
首次登录账号:
rootsudo cat /etc/gitlab/initial_root_password
sudo gitlab-ctl reconfigure # 重新加载配置
sudo gitlab-ctl restart # 重启
sudo gitlab-ctl status # 查看状态
sudo gitlab-ctl stop # 停止
sudo apt install docker.io -y
sudo systemctl enable --now docker
sudo docker run -d \
--hostname gitlab.example.com \
-p 80:80 -p 443:443 -p 22:22 \
--name gitlab \
gitlab/gitlab-ce:latest
访问:
http://服务器IP
修改:
sudo nano /etc/gitlab/gitlab.rb
external_url 'http://IP:8080'
然后:
sudo gitlab-ctl reconfigure
GitLab 至少 4G 内存,2G 容易卡死。
可使用 Let’s Encrypt:
external_url 'https://gitlab.example.com'
letsencrypt['enable'] = true
| 场景 | 推荐方式 |
|---|---|
| 生产服务器 | Omnibus |
| 快速测试 | Docker |
| 云服务器 | Omnibus + 域名 |
如果你告诉我:
我可以给你 更精确的命令。