🦝
wsl2(Linux)でGitLabを動かしてみた
はじめに
前回、こちらの記事でWindows上でLinuxを利用できるようにしたので、ここにGitLabを使えるようにします。
※今回はローカルマシン上で起動させます。
事前準備
- IPアドレスの確認
inet xxx.xxx.xxx.xxx/20 の部分が割り当てられてるIPアドレス$ ip a show dev eth0 | grep eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 inet xxx.xxx.xxx.xxx/20 brd xxx.xxx.xxx.xxx scope global eth0
インストール
-
公式サイトのインストール手順に従って進める
-
sudo コマンドを実行した場合、パスワードの入力を求められることがある
-
「1.必要な依存関係をインストールして設定する」を実行
- 実行コマンド
sudo apt-get update sudo apt-get install -y curl openssh-server ca-certificates tzdata perl # 外部SMTP(Postfix)のインストール ※省略 or 別サービス可(今回はスキップ) sudo apt-get install -y postfix
- 実行結果
$ sudo apt-get update Hit:1 http://archive.ubuntu.com/ubuntu noble InRelease Get:2 http://security.ubuntu.com/ubuntu noble-security InRelease [126 kB] Get:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease [126 kB] Get:4 http://archive.ubuntu.com/ubuntu noble-backports InRelease [126 kB] Get:5 http://security.ubuntu.com/ubuntu noble-security/main amd64 Packages [615 kB] Get:6 http://archive.ubuntu.com/ubuntu noble/universe amd64 Packages [15.0 MB] Get:7 http://security.ubuntu.com/ubuntu noble-security/main Translation-en [118 kB] Get:8 http://security.ubuntu.com/ubuntu noble-security/main amd64 Components [8976 B] Get:9 http://security.ubuntu.com/ubuntu noble-security/universe amd64 Packages [803 kB] Get:10 http://security.ubuntu.com/ubuntu noble-security/universe Translation-en [171 kB] Get:11 http://security.ubuntu.com/ubuntu noble-security/universe amd64 Components [52.0 kB] Get:12 http://security.ubuntu.com/ubuntu noble-security/universe amd64 c-n-f Metadata [13.5 kB] Get:13 http://security.ubuntu.com/ubuntu noble-security/restricted amd64 Packages [620 kB] Get:14 http://security.ubuntu.com/ubuntu noble-security/restricted Translation-en [119 kB] Get:15 http://security.ubuntu.com/ubuntu noble-security/restricted amd64 Components [208 B] Get:16 http://security.ubuntu.com/ubuntu noble-security/multiverse amd64 Packages [12.4 kB] Get:17 http://security.ubuntu.com/ubuntu noble-security/multiverse Translation-en [2940 B] Get:18 http://security.ubuntu.com/ubuntu noble-security/multiverse amd64 Components [208 B] Get:19 http://archive.ubuntu.com/ubuntu noble/universe Translation-en [5982 kB] Get:20 http://security.ubuntu.com/ubuntu noble-security/multiverse amd64 c-n-f Metadata [356 B] Get:21 http://archive.ubuntu.com/ubuntu noble/universe amd64 Components [3871 kB] Get:22 http://archive.ubuntu.com/ubuntu noble/universe amd64 c-n-f Metadata [301 kB] Get:23 http://archive.ubuntu.com/ubuntu noble/multiverse amd64 Packages [269 kB] Get:24 http://archive.ubuntu.com/ubuntu noble/multiverse Translation-en [118 kB] Get:25 http://archive.ubuntu.com/ubuntu noble/multiverse amd64 Components [35.0 kB] Get:26 http://archive.ubuntu.com/ubuntu noble/multiverse amd64 c-n-f Metadata [8328 B] Get:27 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages [838 kB] Get:28 http://archive.ubuntu.com/ubuntu noble-updates/main Translation-en [190 kB] Get:29 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Components [151 kB] Get:30 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Packages [1002 kB] Get:31 http://archive.ubuntu.com/ubuntu noble-updates/universe Translation-en [250 kB] Get:32 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Components [313 kB] Get:33 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 c-n-f Metadata [19.9 kB] Get:34 http://archive.ubuntu.com/ubuntu noble-updates/restricted amd64 Packages [631 kB] Get:35 http://archive.ubuntu.com/ubuntu noble-updates/restricted Translation-en [121 kB] Get:36 http://archive.ubuntu.com/ubuntu noble-updates/restricted amd64 Components [212 B] Get:37 http://archive.ubuntu.com/ubuntu noble-updates/multiverse amd64 Packages [16.3 kB] Get:38 http://archive.ubuntu.com/ubuntu noble-updates/multiverse Translation-en [3944 B] Get:39 http://archive.ubuntu.com/ubuntu noble-updates/multiverse amd64 Components [940 B] Get:40 http://archive.ubuntu.com/ubuntu noble-updates/multiverse amd64 c-n-f Metadata [552 B] Get:41 http://archive.ubuntu.com/ubuntu noble-backports/main amd64 Components [208 B] Get:42 http://archive.ubuntu.com/ubuntu noble-backports/main amd64 c-n-f Metadata [112 B] Get:43 http://archive.ubuntu.com/ubuntu noble-backports/universe amd64 Packages [13.4 kB] Get:44 http://archive.ubuntu.com/ubuntu noble-backports/universe Translation-en [11.4 kB] Get:45 http://archive.ubuntu.com/ubuntu noble-backports/universe amd64 Components [17.6 kB] Get:46 http://archive.ubuntu.com/ubuntu noble-backports/universe amd64 c-n-f Metadata [1104 B] Get:47 http://archive.ubuntu.com/ubuntu noble-backports/restricted amd64 Components [216 B] Get:48 http://archive.ubuntu.com/ubuntu noble-backports/restricted amd64 c-n-f Metadata [116 B] Get:49 http://archive.ubuntu.com/ubuntu noble-backports/multiverse amd64 Components [212 B] Get:50 http://archive.ubuntu.com/ubuntu noble-backports/multiverse amd64 c-n-f Metadata [116 B] Fetched 32.1 MB in 5s (5889 kB/s) Reading package lists... Done
$ sudo apt-get install -y curl openssh-server ca-certificates tzdata perl Reading package lists... Done Building dependency tree... Done Reading state information... Done curl is already the newest version (8.5.0-2ubuntu10.6). curl set to manually installed. ca-certificates is already the newest version (20240203). ca-certificates set to manually installed. The following additional packages will be installed: libperl5.38t64 libwrap0 ncurses-term openssh-sftp-server perl-base perl-modules-5.38 ssh-import-id Suggested packages: molly-guard monkeysphere ssh-askpass ufw perl-doc libterm-readline-gnu-perl | libterm-readline-perl-perl make libtap-harness-archive-perl The following NEW packages will be installed: libwrap0 ncurses-term openssh-server openssh-sftp-server ssh-import-id The following packages will be upgraded: libperl5.38t64 perl perl-base perl-modules-5.38 tzdata 5 upgraded, 5 newly installed, 0 to remove and 77 not upgraded. Need to get 11.2 MB of archives. After this operation, 6856 kB of additional disk space will be used. Get:1 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 libperl5.38t64 amd64 5.38.2-3.2build2.1 [4867 kB] Get:2 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 perl amd64 5.38.2-3.2build2.1 [231 kB] Get:3 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 perl-base amd64 5.38.2-3.2build2.1 [1823 kB] Get:4 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 perl-modules-5.38 all 5.38.2-3.2build2.1 [3110 kB] Get:5 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 openssh-sftp-server amd64 1:9.6p1-3ubuntu13.5 [37.3 kB] Get:6 http://archive.ubuntu.com/ubuntu noble/main amd64 libwrap0 amd64 7.6.q-33 [47.9 kB] Get:7 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 openssh-server amd64 1:9.6p1-3ubuntu13.5 [509 kB] Get:8 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 tzdata all 2024b-0ubuntu0.24.04 [273 kB] Get:9 http://archive.ubuntu.com/ubuntu noble/main amd64 ncurses-term all 6.4+20240113-1ubuntu2 [275 kB] Get:10 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 ssh-import-id all 5.11-0ubuntu2.24.04.1 [10.1 kB] Fetched 11.2 MB in 3s (3801 kB/s) Preconfiguring packages ... (Reading database ... 40794 files and directories currently installed.) Preparing to unpack .../libperl5.38t64_5.38.2-3.2build2.1_amd64.deb ... Unpacking libperl5.38t64:amd64 (5.38.2-3.2build2.1) over (5.38.2-3.2build2) ... Preparing to unpack .../perl_5.38.2-3.2build2.1_amd64.deb ... Unpacking perl (5.38.2-3.2build2.1) over (5.38.2-3.2build2) ... Preparing to unpack .../perl-base_5.38.2-3.2build2.1_amd64.deb ... Unpacking perl-base (5.38.2-3.2build2.1) over (5.38.2-3.2build2) ... Setting up perl-base (5.38.2-3.2build2.1) ... (Reading database ... 40794 files and directories currently installed.) Preparing to unpack .../0-perl-modules-5.38_5.38.2-3.2build2.1_all.deb ... Unpacking perl-modules-5.38 (5.38.2-3.2build2.1) over (5.38.2-3.2build2) ... Selecting previously unselected package openssh-sftp-server. Preparing to unpack .../1-openssh-sftp-server_1%3a9.6p1-3ubuntu13.5_amd64.deb ... Unpacking openssh-sftp-server (1:9.6p1-3ubuntu13.5) ... Selecting previously unselected package libwrap0:amd64. Preparing to unpack .../2-libwrap0_7.6.q-33_amd64.deb ... Unpacking libwrap0:amd64 (7.6.q-33) ... Selecting previously unselected package openssh-server. Preparing to unpack .../3-openssh-server_1%3a9.6p1-3ubuntu13.5_amd64.deb ... Unpacking openssh-server (1:9.6p1-3ubuntu13.5) ... Preparing to unpack .../4-tzdata_2024b-0ubuntu0.24.04_all.deb ... Unpacking tzdata (2024b-0ubuntu0.24.04) over (2024a-3ubuntu1.1) ... Selecting previously unselected package ncurses-term. Preparing to unpack .../5-ncurses-term_6.4+20240113-1ubuntu2_all.deb ... Unpacking ncurses-term (6.4+20240113-1ubuntu2) ... Selecting previously unselected package ssh-import-id. Preparing to unpack .../6-ssh-import-id_5.11-0ubuntu2.24.04.1_all.deb ... Unpacking ssh-import-id (5.11-0ubuntu2.24.04.1) ... Setting up openssh-sftp-server (1:9.6p1-3ubuntu13.5) ... Setting up ssh-import-id (5.11-0ubuntu2.24.04.1) ... Setting up tzdata (2024b-0ubuntu0.24.04) ... Current default time zone: 'Asia/Tokyo' Local time is now: Fri Jan 31 17:12:14 JST 2025. Universal Time is now: Fri Jan 31 08:12:14 UTC 2025. Run 'dpkg-reconfigure tzdata' if you wish to change it. Setting up libwrap0:amd64 (7.6.q-33) ... Setting up perl-modules-5.38 (5.38.2-3.2build2.1) ... Setting up libperl5.38t64:amd64 (5.38.2-3.2build2.1) ... Setting up ncurses-term (6.4+20240113-1ubuntu2) ... Setting up openssh-server (1:9.6p1-3ubuntu13.5) ... Creating config file /etc/ssh/sshd_config with new version Creating SSH2 RSA key; this may take some time ... 3072 SHA256:xxxxxx root@hogehoge (RSA) Creating SSH2 ECDSA key; this may take some time ... 256 SHA256:xxxxxx root@hogehoge (ECDSA) Creating SSH2 ED25519 key; this may take some time ... 256 SHA256:xxxxxx root@hogehoge (ED25519) Created symlink /etc/systemd/system/sockets.target.wants/ssh.socket → /usr/lib/systemd/system/ssh.socket. Created symlink /etc/systemd/system/ssh.service.requires/ssh.socket → /usr/lib/systemd/system/ssh.socket. Setting up perl (5.38.2-3.2build2.1) ... Processing triggers for man-db (2.12.0-4build2) ... Processing triggers for libc-bin (2.39-0ubuntu8.3) ...
- 実行コマンド
-
「2. GitLabパッケージリポジトリを追加してパッケージをインストール」を実行
-
実行コマンド
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash # target_urlは任意のURLを指定可能。httpsでする場合は証明書が必要。 # gitlabのバージョンは指定可能。詳細は公式サイトで確認を target_url=https://gitlab.example.com sudo EXTERNAL_URL="$target_url" apt-get install gitlab-ee
-
実行結果
$ curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 6865 100 6865 0 0 22888 0 --:--:-- --:--:-- --:--:-- 22959 Detected operating system as Ubuntu/noble. Checking for curl... Detected curl... Checking for gpg... Detected gpg... Running apt-get update... done. Installing apt-transport-https... done. Installing /etc/apt/sources.list.d/gitlab_gitlab-ee.list...done. Importing packagecloud gpg key... done. Running apt-get update... done. The repository is setup! You can now install packages.
$ target_url=http://gitlab.test.com $ sudo EXTERNAL_URL="$target_url" apt-get install gitlab-ee ...コンソールに大量に出力されるので割愛。最後に下記の表示となる。
-
GitLabへアクセス
-
今回はDNS登録してないので、IPでアクセス
http://xxx.xxx.xxx.xxx
正しく起動していたら下記の画面が表示されます
-
rootユーザで入ろうとしたらパスワードがわからない、、
よく見たらgitlabインストール時に入力せんかったら、ランダムになるて書いてる・・
しかも24時間で消えるって、、困るー$ sudo 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: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz # NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
-
長いパスワードでログイン
番外編:rootユーザのパスワード変更
-
rootユーザの自動設定パスワードが24時間で消えるので変更
/etc/gitlab/initial_root_password に下記の記載があるので、URL先を確認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.
-
案内に従ってRake taskでパスワード変更を行う
$ sudo gitlab-rake "gitlab:password:reset" root Enter username: Enter password: Confirm password: Unable to change password of the user with username root. Password must not contain commonly used combinations of words and letters
-
が、うまくいかず断念。。とりあえずログインできたのでここまで。
Discussion