在 Debian 上配置 GitLab,通常推荐使用 GitLab 官方 Omnibus 包,部署简单、维护方便。下面按步骤说明。
sudo apt update
sudo apt upgrade -y
sudo apt install -y curl openssh-server ca-certificates postfix
postfix:用于邮件通知curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash
社区版用
gitlab-ce,企业版用gitlab-ee
sudo EXTERNAL_URL="http://gitlab.example.com" apt install gitlab-ee
如果是本地服务器:
sudo EXTERNAL_URL="http://192.168.1.100" apt install gitlab-ee
sudo gitlab-ctl reconfigure
首次配置会花几分钟。
浏览器打开:
http://你的IP或域名
默认用户:
rootsudo cat /etc/gitlab/initial_root_password
sudo nano /etc/gitlab/gitlab.rb
常见配置:
external_url 'http://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
使用 Let’s Encrypt:
external_url 'https://gitlab.example.com'
letsencrypt['enable'] = true
letsencrypt['auto_renew'] = true
然后:
sudo gitlab-ctl reconfigure
修改:
nginx['listen_port'] = 8080
并重写 external_url 带上端口。
可关闭部分服务(如 registry、pages):
registry['enable'] = false
gitlab_pages['enable'] = false
如果你愿意,我可以:
你目前是本地测试还是生产环境?