Installing GitLab CE on Ubuntu 22.04
What is GitLab CE?
GitLab Community Edition is the open-source, self-hostable version of GitLab — version control, code review, CI/CD, container registry, the lot. You can run it on your own hardware, in a container, or on any cloud VM. This post is a step-by-step install of GitLab CE.
The official sizing recommendations live in the GitLab repo: see the install requirements doc. For a small setup with GitLab CE plus a runner you're looking at roughly 5 vCPU and 8 GB RAM total — 1 vCPU / 4 GB for GitLab, 4 vCPU / 4 GB for the runner. This guide installs only GitLab CE; the runner is a separate post.
What you'll need
- Ubuntu 22.04
- Inbound 80/443 if you want web access from outside the host
Install
Install the OS prereqs:
sudo apt install -y ca-certificates curl openssh-server tzdatasudo apt install -y curl debian-archive-keyring lsb-release ca-certificates apt-transport-https software-properties-commonAdd the GitLab CE apt repo and key:
curl https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey | sudo apt-key add -sudo tee /etc/apt/sources.list.d/gitlab_gitlab-ce.list <<EOFdeb https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ focal maindeb-src https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ focal mainEOFRefresh apt and install:
sudo apt updatesudo apt install gitlab-ceWhen the install finishes you'll see something like:
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 reconfigureConfigure
Set the external_url in gitlab.rb:
sudo vim /etc/gitlab/gitlab.rbexternal_url 'http://git.example.com'If you set this to an
https://URL, GitLab will automatically request a Let's Encrypt cert (assuming the host is reachable from the internet on port 80/443). Easy way to get HTTPS without managing certs by hand.
Apply the new config:
sudo gitlab-ctl reconfigureFirst login
Browse to the URL you just set.
The initial root password lives on the server (it's deleted automatically after 24 hours, so grab it now):
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.Password: L03vB0I4N5/eFRrbDfbSmTjktL4+Zi9759gxSyhYzRY=# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.Log in as root with that password and change it immediately under Profile → Edit profile → Password.