在 Ubuntu 上安装 GitLab 通常有两种常见方式:
下面我分别说明,最常用的是 方式一。
sudo apt update
sudo apt upgrade -y
sudo apt install -y curl openssh-server ca-certificates tzdata perl
如果需要邮件通知,可以安装 Postfix(可选):
sudo apt install -y postfix
(安装时选择 Internet Site 即可)
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash
如果你要用 社区版(CE),把上面命令中的
gitlab-ee改成gitlab-ce:
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo EXTERNAL_URL="http://your-domain-or-ip" apt install gitlab-ee
例如:
sudo EXTERNAL_URL="http://192.168.1.100" apt install gitlab-ee
如果是 CE:
sudo EXTERNAL_URL="http://gitlab.example.com" apt install gitlab-ce
安装完成后,在浏览器打开:
http://your-domain-or-ip
首次登录账号:
rootsudo cat /etc/gitlab/initial_root_password
sudo gitlab-ctl reconfigure # 修改配置后执行
sudo gitlab-ctl restart
sudo gitlab-ctl status
sudo apt install docker.io docker-compose -y
sudo systemctl enable --now docker
sudo docker run --detach \
--hostname gitlab.example.com \
--publish 443:443 --publish 80:80 --publish 22:22 \
--name gitlab \
--volume /srv/gitlab/config:/etc/gitlab \
--volume /srv/gitlab/logs:/var/log/gitlab \
--volume /srv/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ee:latest
访问:
http://服务器IP
可修改 /etc/gitlab/gitlab.rb:
external_url 'http://ip:8080'
nginx['listen_port'] = 8080
然后:
sudo gitlab-ctl reconfigure
如果你告诉我:
我可以给你更精确的安装方案。