搭建自己私人的gitlab server

使用環境

OS:ubuntu 20.04 LTS ## 安裝

1
2
3
4
5
6
7
8
9
sudo apt-get update
sudo apt-get install -y curl openssh-server ca-certificates tzdata perl
sudo apt-get install -y postfix
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash


#gitlab.example.com這裡請設定自己的網域或主機的IP位置
sudo EXTERNAL_URL="https://gitlab.example.com" apt-get install gitlab-ee

安裝過程時添加SSL

1
2
3
4
mkdir /etc/gitlab/ssl
## 如果資料夾已存在可略過
sudo chmod 700 /etc/gitlab/ssl
vim /etc/gitlab/gitlab.rb

參數調整成以下

1
2
3
4
5
6
nginx['enable'] = true
nginx['redirect_http_to_https'] = true
nginx['redirect_http_to_https_port'] = 80
nginx['ssl_certificate'] = "/etc/gitlab/ssl/<"自己的網域名稱">.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/<"自己的網域名稱">.key"

重新載入設定

1
2
3
4
gitlab-ctl reconfigure

gitlab-ctl restart

開機時啟動

1
gitlab-ctl enable

防火牆設定

1
2
3
4
5
sudo ufw allow http
sudo ufw allow https
sudo ufw allow OpenSSH
sudo ufw reload

參考資料

  1. https://about.gitlab.com/install/
  2. https://b8807053.pixnet.net/blog/post/344785258-gitlab-https