如何在 Debian 11 上安裝 Gitlab


本教程將向您展示如何在 Debian 11 上安裝 Gitlab。對於不熟悉的人來說,GitLab 是一個基於 Web 的版本控制系統和基於 Git 的協作軟件開發。它與 GitHub 非常相似,提供了一個 wiki、問題跟踪和一個提供持續集成和部署的 Git 存儲庫管理器。 GitLab 可用於許多 Linux 發行版。 GitLab 提供免費和付費計劃來幫助您發展業務。

本文假設您至少具備 Linux 的基本知識,知道如何使用 shell,最重要的是,您將網站託管在自己的 VPS 上。 假設您在 root 帳戶下運行,安裝非常簡單。sudo‘ 獲取 root 權限的命令。 我將逐步向您展示如何在 Debian 11 (Bullseye) 上安裝 Gitlab。

在 Debian 11 Bullseye 上安裝 Gitlab

步驟 1. 在安裝任何軟件之前,請通過運行以下命令確保您的系統是最新的: apt 終端中的命令:

sudo apt update
sudo apt upgrade
sudo apt install curl ca-certificates apt-transport-https gnupg2

步驟 2. 在 Debian 11 上安裝 Gitlab。

Gitlab 默認在 Debian 11 基礎存儲庫中不可用。讓我們使用以下命令將 GitLab 存儲庫添加到我們的系統中:

curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | bash

在編寫本教程時,GitLab 軟件包不適用於 Debian 11。 編輯 GitLab 源文件並將 Debian 11 代號替換為 Debian 10。

nano /etc/apt/sources.list.d/gitlab_gitlab-ce.list

找到這一行:

deb https://packages.gitlab.com/gitlab/gitlab-ce/debian/ bullseye main
deb-src https://packages.gitlab.com/gitlab/gitlab-ce/debian/ bullseye main

利用。 . .排除:

deb https://packages.gitlab.com/gitlab/gitlab-ce/debian/ buster main
deb-src https://packages.gitlab.com/gitlab/gitlab-ce/debian/ buster main

保存、關閉並安裝 GitLab,如下所示:

sudo apt update
sudo apt install gitlab-ce

步驟 3. 配置 Gitlab。

現在需要編輯 gitlab.rb 找到文件 external_url 編輯字符串以將其更改為服務器的 IP 地址或域。

nano /etc/gitlab/gitlab.rb

換行:

external_url 'https://gitlab.idroot.us'

然後通過更改以下行來啟用 SSL:

# Enable the Let's encrypt SSL
letsencrypt['enable'] = true

# This is optional to get SSL related alerts
letsencrypt['contact_emails'] = ['[email protected]']

# This example renews every 7th day at 02:00 AM
letsencrypt['auto_renew_hour'] = "5"
letsencrypt['auto_renew_minute'] = "0"
letsencrypt['auto_renew_day_of_month'] = "*/7"

保存並關閉文件。通過運行以下命令重新配置 Gitlab:

gitlab-ctl reconfigure

步驟 4. 配置您的防火牆。

防火牆用戶可以使用以下命令打開其係統上所需的端口:

sudo firewall-cmd --permanent --zone=public --add-service=http 
sudo firewall-cmd --permanent --zone=public --add-service=https 
sudo firewall-cmd --reload

第 5 步:在 Debian 上訪問 Gitlab。

成功安裝後,使用 URL 訪問 GitLab 儀表板。 https://gitlab.idroot.us您將被重定向到可以更改 Gitlab 管理員密碼的頁面。

在 Debian 11 Bullseye 上安裝 Gitlab

恭喜! 你已經成功安裝了 Gitlab。感謝您使用本教程在 Debian 11 Bullseye 上安裝最新版本的 Gitlab。如需更多幫助或有用信息,我們建議您查看 Gitlab官方網站.