これは、なにをしたくて書いたもの?
久しぶりにGitLab環境を作ってみようかなと思いまして、今のバージョンのGitLab Community Editionを
Ubuntu Linux 24.04 LTSにインストールしてみます。
GitLabのインストール方法
GitLabのドキュメントで、インストールに関するページはこちら。
実のところ、インストーラーのページにたどり着くまでが1番大変な気がします…。
ドキュメントを、次のようにたどっていきます。
Installation methods | GitLab Docs
Linux package documentation | GitLab Docs
Install GitLab with the Linux package | GitLab Docs
Linux OSにセルフホスティングするには、Omunibusパッケージを使います。
ここで、Install GitLab with the Linux package / Installation and Configurationにある最初のInstalling GitLabという
リンクがOmunibusパッケージのページへ遷移するリンクになります。
Download and install GitLab | GitLab
とても見つけにくいです…。
Ubuntu Linuxの場合は、こちらの手順に従います。
Official Linux package / Ubuntu
サポートしているLinux OSの一覧について書かれたページはこちらで、このページからもOmunibusパッケージのページへ
たどり着くことができます。
Supported operating systems | GitLab Docs
ちなみに、アンインストール方法についてはこちら。
Install GitLab with the Linux package / Uninstall the Linux package (Omnibus)
では、実際にGitLab Community Editionをインストールしましょう。
環境
今回の環境はこちら。
$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 24.04.2 LTS Release: 24.04 Codename: noble $ uname -srvmpio Linux 6.8.0-55-generic #57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
GItLab Community Editionをインストールする
それでは、こちらの手順に従ってGitLab Community Editionをインストールします。
Official Linux package / Ubuntu
必要なパッケージのインストール。
$ sudo apt-get update $ sudo apt-get install -y curl openssh-server ca-certificates tzdata perl
Postfixはメール通知を使う場合はインストールします。今回はパスします。
$ sudo apt-get install -y postfix
ここから先は、GitLab Community Edition(GitLab CE)とGitLab Enterprise Edition(GitLab EE)で手順が少し異なります。
ドキュメントはGitLab EEのもので書かれているので、GitLab CEのものも載せていきます。
aptリポジトリーの追加。
## GitLab CE $ curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash ## GitLab EE $ curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash
パッと見で気づきにくいんですが、gitlab-ce
とgitlab-ee
の差があります。
今回はGitLab CE向けのスクリプトを実行しています。
GitLab CEのパッケージが認識されました。
$ apt show gitlab-ce Package: gitlab-ce Version: 17.9.2-ce.0 Priority: extra Section: misc Maintainer: GitLab, Inc. <support@gitlab.com> Installed-Size: 3,750 MB Depends: openssh-server, perl Conflicts: gitlab-ee, gitlab-fips, gitlab Replaces: gitlab-ee, gitlab-fips, gitlab Homepage: https://about.gitlab.com/ Download-Size: 1,381 MB APT-Sources: https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu noble/main amd64 Packages Description: GitLab Community Edition (including NGINX, Postgres, Redis) N: 追加レコードが 57 件あります。表示するには '-a' スイッチを付けてください。
インストールするコマンドはこちら。EXTERNAL_URL
にはGitLabにアクセスする時のURLを指定します。
## GitLab CE $ sudo EXTERNAL_URL="[GitLabにアクセスする際のURL]" apt-get install gitlab-ce ## GitLab EE $ sudo EXTERNAL_URL="[GitLabにアクセスする際のURL]" apt-get install gitlab-ee
環境変数には、他にはrootアカウントのパスワードやメールアドレスを指定できます。
Install GitLab with the Linux package / Installation and Configuration / Set up the initial account
rootアカウントの初期パスワードを合わせて設定する場合はこちら。
## GitLab CE $ sudo GITLAB_ROOT_PASSWORD="rootアカウントの初期パスワード" EXTERNAL_URL="[GitLabにアクセスする際のURL]" apt-get install gitlab-ce ## GitLab EE $ sudo GITLAB_ROOT_PASSWORD="rootアカウントの初期パスワード" EXTERNAL_URL="[GitLabにアクセスする際のURL]" apt-get install gitlab-ee
rootアカウントのパスワードを指定しなかった場合は、/etc/gitlab/initial_root_password
ファイルにランダムなパスワードが
生成されます。
今回は以下のコマンドでインストールしました。
$ sudo EXTERNAL_URL="http://192.168.0.6" apt-get install gitlab-ce
インストールが完了しました。
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! *. *. *** *** ***** ***** .****** ******* ******** ******** ,,,,,,,,,***********,,,,,,,,, ,,,,,,,,,,,*********,,,,,,,,,,, .,,,,,,,,,,,*******,,,,,,,,,,,, ,,,,,,,,,*****,,,,,,,,,. ,,,,,,,****,,,,,, .,,,***,,,, ,*,. _______ __ __ __ / ____(_) /_/ / ____ _/ /_ / / __/ / __/ / / __ `/ __ \ / /_/ / / /_/ /___/ /_/ / /_/ / \____/_/\__/_____/\__,_/_.___/ Thank you for installing GitLab! GitLab should be available at http://192.168.0.6 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=17-9
rootアカウントのパスワードは、こちらに出力されています。
Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours.
バージョン。
$ sudo gitlab-rake gitlab:env:info System information System: Ubuntu 24.04 Current User: git Using RVM: no Ruby Version: 3.2.5 Gem Version: 3.6.3 Bundler Version:2.5.11 Rake Version: 13.0.6 Redis Version: 7.0.15 Sidekiq Version:7.2.4 Go Version: unknown GitLab information Version: 17.9.2 Revision: 3ddc2ace157 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 14.17 URL: http://192.168.0.6 HTTP Clone URL: http://192.168.0.6/some-group/some-project.git SSH Clone URL: git@192.168.0.6:some-group/some-project.git Using LDAP: no Using Omniauth: yes Omniauth Providers: GitLab Shell Version: 14.40.0 Repository storages: - default: unix:/var/opt/gitlab/gitaly/gitaly.socket GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell Gitaly - default Address: unix:/var/opt/gitlab/gitaly/gitaly.socket - default Version: 17.9.2 - default Git Version: 2.47.2
EXTERNAL_URL
で指定したURLにアクセスして確認。
OKですね。
GitLabの起動・停止コマンドなどは、こちらのページに記載があります。
Maintenance commands | GitLab Docs
ステータス確認。
$ sudo gitlab-ctl status run: alertmanager: (pid 42031) 371s; run: log: (pid 41851) 407s run: gitaly: (pid 41968) 374s; run: log: (pid 41218) 550s run: gitlab-exporter: (pid 41983) 373s; run: log: (pid 41742) 427s run: gitlab-kas: (pid 41501) 530s; run: log: (pid 41512) 529s run: gitlab-workhorse: (pid 41950) 376s; run: log: (pid 41662) 444s run: logrotate: (pid 41134) 567s; run: log: (pid 41160) 564s run: nginx: (pid 41963) 376s; run: log: (pid 41685) 438s run: node-exporter: (pid 41977) 375s; run: log: (pid 41726) 432s run: postgres-exporter: (pid 42041) 372s; run: log: (pid 41881) 402s run: postgresql: (pid 41283) 542s; run: log: (pid 41294) 541s run: prometheus: (pid 42012) 373s; run: log: (pid 41784) 414s run: puma: (pid 41569) 459s; run: log: (pid 41583) 456s run: redis: (pid 41170) 561s; run: log: (pid 41189) 558s run: redis-exporter: (pid 41989) 374s; run: log: (pid 41768) 419s run: sidekiq: (pid 41590) 453s; run: log: (pid 41598) 452s
設定確認。
$ sudo gitlab-ctl show-config
起動。
$ sudo gitlab-ctl start
停止。
$ sudo gitlab-ctl stop
再起動。
$ sudo gitlab-ctl restart
おわりに
Ubuntu Linux 24.04 LTSに、GitLab Community Edition 17をインストールしてみました。
GitLabはたまにインストールしているのですが、Omnibusパッケージのページがどこにあるかを探すのにいつも苦労している
気がします(笑)。
GitLabを使ってやりたいこともあったりするので、今後少しずつ使っていってみようかなと思います。