下面给你一个**在 Debian 上自建 GitLab(CE 社区版)**的实用步骤,适用于 Debian 11 / 12,以 官方 Omnibus 包 方式安装(最省心、最常用)。
sudo apt update
sudo apt upgrade -y
sudo apt install -y curl openssh-server ca-certificates tzdata perl
(可选,发送邮件用)
sudo apt install -y postfix
选 Internet Site,填域名即可
curl -fsSL https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo EXTERNAL_URL="https://gitlab.example.com" apt install gitlab-ce
sudo EXTERNAL_URL="http://192.168.1.100" apt install gitlab-ce
安装完成后会自动:
sudo cat /etc/gitlab/initial_root_password
⚠️ 该文件 24 小时后自动删除
https://gitlab.example.com
或
http://服务器IP
用 root 登录,立即修改密码。
sudo nano /etc/gitlab/gitlab.rb
示例:
external_url 'https://gitlab.example.com'
gitlab_rails['gitlab_email_from'] = 'gitlab@example.com'
sudo gitlab-ctl reconfigure
sudo gitlab-ctl status
sudo gitlab-ctl restart
sudo gitlab-ctl stop
letsencrypt['enable'] = true
letsencrypt['contact_emails'] = ['admin@example.com']
然后:
sudo gitlab-ctl reconfigure
sudo ufw allow 80
sudo ufw allow 443
sudo ufw allow 22
mattermost['enable'] = false
prometheus['enable'] = false
可以,但 Omnibus 更适合新手和生产
sudo gitlab-rake gitlab:backup:create
sudo apt update
sudo apt install gitlab-ce
如果你愿意,我可以:
你打算 公网还是内网?有没有域名?