在 Debian 上部署 GitLab 通常有两种主流方式:
下面分别说明。
sudo apt update
sudo apt install -y curl openssh-server ca-certificates tzdata perl
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash
如果你要用社区版(CE),把
gitlab-ee换成gitlab-ce
sudo EXTERNAL_URL="http://gitlab.example.com" apt install gitlab-ee
如果是本机测试:
sudo EXTERNAL_URL="http://你的服务器IP" apt install gitlab-ee
sudo gitlab-ctl reconfigure
浏览器打开:
http://服务器IP
首次登录账号:
rootsudo cat /etc/gitlab/initial_root_password
sudo apt install -y docker.io docker-compose
sudo systemctl enable --now docker
version: '3'
services:
gitlab:
image: gitlab/gitlab-ee:latest
container_name: gitlab
restart: always
hostname: gitlab.example.com
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://服务器IP'
ports:
- "80:80"
- "443:443"
- "22:22"
volumes:
- ./gitlab/config:/etc/gitlab
- ./gitlab/logs:/var/log/gitlab
- ./gitlab/data:/var/opt/gitlab
docker compose up -d
docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password
编辑:
sudo vim /etc/gitlab/gitlab.rb
修改:
external_url 'http://你的域名或IP'
然后:
sudo gitlab-ctl reconfigure
external_url 'https://gitlab.example.com'
letsencrypt['enable'] = true
sudo gitlab-ctl status
sudo gitlab-ctl stop
sudo gitlab-ctl start
sudo gitlab-ctl restart
如果你愿意,我可以:
你目前的 Debian 版本和用途(学习 / 公司内网 / 公网)是?