ウェブサイト検索

Debian 11にGitLabをインストールする方法


Debian 11にGitLabをインストールする方法

このチュートリアルはこれらのOSバージョンのために存在します

  • Debian 11 (Bullseye)
  • Debian 8 (ジェシー)

このページで

  1. 前提条件
  2. 始めに
  3. GitLabリポジトリを追加する
  4. GitLab CEをインストールする
  5. GitLabを設定する
  6. GitLabにアクセスする
  7. GitLabバックアップの設定
  8. 結論

GitLabは、チームがより早く反復し、一緒に革新できる無料のオープンソースのDevOpsプラットフォームです。これは、GitLab Inc.によって開発されたWebベースのツールです。GitHubに非常に似ており、ウィキ、イシュートラッキング、継続的インテグレーションおよびデプロイメントを提供するGitリポジトリマネージャーを提供します。GitLabコミュニティエディションは、開発および本番環境向けに完全に無料で利用可能です。

このチュートリアルでは、Debian 11 に Nginx と Let's Encrypt SSL を使用して GitLab をインストールする方法を示します。

前提条件

  • 最小8GBのRAMを搭載したDebian 11を実行しているサーバー。
  • サーバーIPにポイントされた有効なドメイン名。
  • サーバーにはルートパスワードが設定されています。

始めに

開始する前に、パッケージキャッシュを最新バージョンに更新することをお勧めします。次のコマンドで実行できます:

apt-get update -y

完了したら、次のコマンドを使用して他の必要な依存関係をインストールしてください:

apt-get install curl ca-certificates apt-transport-https gnupg2 -y

必要な依存関係がすべてインストールされると、次のステップに進むことができます。

GitLabリポジトリを追加する

デフォルトでは、GitLabパッケージはDebianのデフォルトリポジトリにはありません。したがって、APTにGitLabリポジトリを追加する必要があります。

次のスクリプトを実行することで追加できます:

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

これにより、GitLab リポジトリが APT ソースリストファイルに追加されます。

この記事を書いている時点では、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

ファイルを保存して閉じ、その後、以下のコマンドでリポジトリを更新してください:

apt-get update -y

GitLab CEをインストールする

次のコマンドを実行することでGitLab CEをインストールできます:

apt-get install gitlab-ce -y

GitLabがインストールされると、以下の出力が得られるはずです。

It looks like GitLab has not been configured yet; skipping the upgrade script.

       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.
  


     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/
  

Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
  sudo gitlab-ctl reconfigure

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

Help us improve the installation experience, let us know how we did with a 1 minute survey:
https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=14-3

GitLabを設定する

この時点で、GitLabはあなたのシステムにインストールされていますが、まだ設定されていません。次のファイルを編集することで設定できます。

nano /etc/gitlab/gitlab.rb

次の行をあなたのドメイン名に変更してください:

external_url 'https://gitlab.linuxbuz.com'

次に、以下の行を変更してLet's Encrypt SSLを有効にします:

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

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

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

ファイルを保存して閉じたら、次のコマンドを使用してGitLabを再設定します:

gitlab-ctl reconfigure

GitLabの再設定が完了すると、次の出力が表示され、GitLabアクセスパスワードが含まれます:

Notes:
Default admin account has been configured with following details:
Username: root
Password: You didn't opt-in to print initial root password to STDOUT.
Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours.

NOTE: Because these credentials might be present in your log files in plain text, it is highly recommended to reset the password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

gitlab Reconfigured!

次に、以下のコマンドを使用してGitLabのアクセスパスワードを取得します:

cat /etc/gitlab/initial_root_password

次の出力が表示されるはずです:

WARNING: This value is valid only in the following conditions
         1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
         2. Password hasn't been changed manually, either via UI or via command line.
#
         If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

Password: WBgnk2SH4xK5FeJVsJX0Qo79IeyE5LSTGWm3EjDVEkw=

NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.

GitLabにアクセスする

今すぐ、URL https://gitlab.linuxbuz.com を使用してGitLabダッシュボードにアクセスできます。GitLabのログインページにリダイレクトされます:

ユーザー名とパスワードを入力し、サインインボタンをクリックしてください。次の画面にGitLabのダッシュボードが表示されるはずです:

GitLabバックアップを設定する

インストール後、GitLabの完全なバックアップを取ることをお勧めします。次のコマンドを使用してバックアップできます:

gitlab-rake gitlab:backup:create

バックアップは /etc/crontab ファイルを編集することでスケジュールすることもできます。

nano /etc/crontab

次の行を追加してください:

0   22  *  *  *   root gitlab-rake gitlab:backup:create

作業が完了したら、ファイルを保存して閉じてください。

結論

おめでとうございます!あなたはDebian 11にNginxとLet's Encrypt SSLを使ってGitLabを成功裏にインストールしました。これで開発環境にGitLabを実装して、ソフトウェア開発プロセスをより速くすることができます。何か質問があれば、遠慮なく聞いてください。

関連記事: