How to Install Gitlab on Ubuntu 24.04 with SSL/TLS

|
Published:
|
|
install gitlab on ubuntu 24.04

In this tutorial, you will learn how to install Gitlab on Ubuntu 24.04. GitLab is an open source end-to-end software development platform with built-in version control, issue tracking, code review, CI/CD, etc. It is is a complete DevOps platform, delivered as a single application.

Installing Gitlab on Ubuntu 24.04

System Requirements

Below are the bare minimum software and hardware system requirements to install Gitlab with SSL/TLS certificates on Ubuntu 24.04.

Hardware Requirements

Ensure the system you want to host with Gitlab has met the following minimum hardware requirements;

  • Storage: Enough storage depending on the size of the repositories you want to store in GitLab.
  • CPU: At least 4 cores. (supports up to 500 users).
  • Memory: At least 4GB RAM (supports up to 500 users).
  • Swap: At least 2GB of swap memory.

For other system requirements, the package installer will take care of it, unless you are doing self compilation.

Read more about the requirements of installing Gitlab on Requirements page.

Install Gitlab

Run system update;

sudo apt update

Run the command below to install some required package dependencies.

sudo apt install curl tzdata ca-certificates

In this tutorial, we are installing Gitlab Community Edition, CE. There are two ways in which you can install Gitlab.

Installing Gitlab using DEB Binary package

To install Gitlab using DEB binary package, download the binary from the Gitlab packages page and install it manually using apt or dpkg commands;

VER=16.11.2

Replace the value of the VER above to current release version.

Again, currently only packages for Noble are not available.

wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/jammy/gitlab-ce_${VER}-ce.0_amd64.deb/download.deb
sudo apt install ./gitlab-ce_${VER}-ce.0_amd64.deb

To automatically configure Gitlab during installation, you can provide the EXTERNAL URL address. Note that you can also change the URL later after installation and reconfigure Gitlab.

Be sure to change the URL, gitlab.kifarunix.com, with your respective domain address.

sudo  EXTERNAL_URL="https://gitlab.kifarunix.com" apt install ./gitlab-ce_${VER}-ce.0_amd64.deb

Sample installation output.

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'gitlab-ce' instead of './gitlab-ce_16.11.2-ce.0_amd64.deb'
The following NEW packages will be installed:
  gitlab-ce
0 upgraded, 1 newly installed, 0 to remove and 11 not upgraded.
Need to get 965 MB of archives.
After this operation, 3,029 MB of additional disk space will be used.
Get:1 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu jammy/main amd64 gitlab-ce amd64 16.11.2-ce.0 [965 MB]
Fetched 965 MB in 9s (106 MB/s)                                                                                                                     
Selecting previously unselected package gitlab-ce.
(Reading database ... 100567 files and directories currently installed.)
Preparing to unpack .../gitlab-ce_16.11.2-ce.0_amd64.deb ...
Unpacking gitlab-ce (16.11.2-ce.0) ...
Setting up gitlab-ce (16.11.2-ce.0) ...
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=16-11

Scanning processes...                                                                                                                                
Scanning linux images...                                                                                                                             

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.

We will configure Gitlab in the next steps.

Install Gitlab from APT Repository

To install Gitlab from APT repository on Ubuntu 24.04, you need to install the Gitlab repo by running the command below;

curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
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-ce.list...done.
Importing packagecloud gpg key... done.
Running apt-get update... done.

The repository is setup! You can now install packages.

Once the Gitlab package repo is done, install Gitlab on Ubuntu 24.04;

NOTE that as of this writing, there are no repos for Ubuntu 24.04. In this case, you can use Ubuntu 22.04 Jammy repos.

Thus, update the repo accordingly;

sudo sed -i 's/noble/jammy/' /etc/apt/sources.list.d/gitlab_gitlab-ce.list
sudo apt update
sudo EXTERNAL_URL="https://gitlab.kifarunix.com" apt install gitlab-ce
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  gitlab-ce
0 upgraded, 1 newly installed, 0 to remove and 11 not upgraded.
Need to get 965 MB of archives.
After this operation, 3,029 MB of additional disk space will be used.
Get:1 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu jammy/main amd64 gitlab-ce amd64 16.11.2-ce.0 [965 MB]
Fetched 965 MB in 9s (111 MB/s)                                                                                                                     
Selecting previously unselected package gitlab-ce.
(Reading database ... 100567 files and directories currently installed.)
Preparing to unpack .../gitlab-ce_16.11.2-ce.0_amd64.deb ...
Unpacking gitlab-ce (16.11.2-ce.0) ...
Setting up gitlab-ce (16.11.2-ce.0) ...
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=16-11

Scanning processes...                                                                                                                                
Scanning linux images...                                                                                                                             

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.

Configure Gitlab on Ubuntu 24.04

Set External URL for GitLab Server

Edit the /etc/gitlab/gitlab.rb configuration file and replace the value of the external_url parameter with your Gitlab server URL.

sudo grep "^external_url" /etc/gitlab/gitlab.rb

Output;

external_url 'http://gitlab.example.com'

Replace the Gitlab external URL domain.

sudo vim /etc/gitlab/gitlab.rb
#external_url 'http://gitlab.example.com'
external_url 'https://gitlab.kifarunix.com'

Notice that I also enabled HTTPS for the domain.

Enable Gitlab SSL/TLS Settings

Once the Gitlab package is installed, you can configure it to use SSL/TLS certificates. There are two ways in which you can configure Gitlab with SSL/TLS certificates;

  1. Using free and automated HTTPS with Let’s Encrypt
  2. Manually configuring HTTPS with your own self signed certificates

Assuming you have already have generated Let’s Encrypt SSL certs;

sudo ls -1 /etc/letsencrypt/live/kifarunix.com
cert.pem
chain.pem
fullchain.pem
privkey.pem
README

You can configure Gitlab to use Let’s Encrypt certs as follows;

sudo vim /etc/gitlab/gitlab.rb

Next, scroll down to Gitlab NGINX section and make the following adjustments (as per your setup).

################################################################################
## GitLab NGINX
##! Docs: https://docs.gitlab.com/omnibus/settings/nginx.html
################################################################################

nginx['enable'] = true 
nginx['client_max_body_size'] = '250m'
nginx['redirect_http_to_https'] = true
...
...
nginx['ssl_certificate'] = "/etc/letsencrypt/live/kifarunix.com/fullchain.pem"
nginx['ssl_certificate_key'] = "/etc/letsencrypt/live/kifarunix.com/privkey.pem"

...
...
nginx['ssl_protocols'] = "TLSv1.2 TLSv1.3"

Save the file and exit.

If you want to use your own self signed SSL/TLS certs, you can generate and use them as follows.

Create a directory to store the SSL certs;

mkdir /etc/gitlab/ssl

Next, generate the self signed SSL certs by running the command below. Be sure to replace the certificates details accordingly in the command below;

openssl req -newkey rsa:4096 -x509 -sha512 -days 3650 -nodes -out /etc/gitlab/ssl/kifarunix-demo.crt -keyout /etc/gitlab/ssl/kifarunix-demo.key -subj "/C=US/ST=California/L=San Francisco/O=Kifarunix-demo Ltd/CN=*.kifarunix-demo.com/"

Copy the public certificate file only into the /etc/gitlab/trusted-certs directory.

mkdir /etc/gitlab/trusted-certs
cp /etc/gitlab/ssl/kifarunix-demo.crt /etc/gitlab/trusted-certs/

Other Gitlab Configurations

There are quite number of configuration options in the /etc/gitlab/gitlab.rb configuration. Go through the configuration and make appropriate changes that suits your needs.

Save and exit the configuration file once you are done with the configurations.

Reconfigure Omnibus GitLab

Once the setup is done, reconfigure Omnibus Gitlab. Reconfiguration is needed whenever there is any configuration changes.

sudo gitlab-ctl reconfigure

Sample command output;

...
Running handlers:
[2024-05-10T06:40:54+00:00] INFO: Running report handlers
Running handlers complete
[2024-05-10T06:40:54+00:00] INFO: Report handlers complete
Infra Phase complete, 557/1595 resources updated in 02 minutes 32 seconds

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.

[2024-05-10T06:40:54+00:00] WARN: This release of Cinc Client became end of life (EOL) on May 1st 2024. Please update to a supported release to receive new features, bug fixes, and security updates.
gitlab Reconfigured!

Are you experiencing long wait to time outs waiting for logrotate socket to appear?

...
* ruby_block[wait for logrotate service socket] action run...

Ensure that the Gitlab runit service supervisor (runsvdir) is running;

systemctl status gitlab-runsvdir.service

If it is not running, restart it;

sudo systemctl restart gitlab-runsvdir.service

Confirm status again!

systemctl status gitlab-runsvdir.service
● gitlab-runsvdir.service - GitLab Runit supervision process
     Loaded: loaded (/usr/lib/systemd/system/gitlab-runsvdir.service; enabled; preset: enabled)
     Active: active (running) since Fri 2024-05-10 06:34:54 UTC; 13s ago
   Main PID: 12092 (runsvdir)
      Tasks: 1 (limit: 4915)
     Memory: 196.0K (peak: 660.0K)
        CPU: 4ms
     CGroup: /system.slice/gitlab-runsvdir.service
             └─12092 runsvdir -P /opt/gitlab/service "log: .................................................................

After that, re-run the reconfiguration.

Based on the summary of reconfiguration, Gitlab login username is root and the password is stored in the file, /etc/gitlab/initial_root_password.

sudo grep Password: /etc/gitlab/initial_root_password
Password: 5KLL7fXIMWPuaSf1qANpKs6scO0ZwwOxY6UhvRiG4NQ=

Reset Gitlab User Password

If you want to reset Gitlab user password, run the command below;

sudo gitlab-rake "gitlab:password:reset"

The command will prompt to enter the username and password.

You can specify the username in command line. Replace the username with respective username.

sudo gitlab-rake "gitlab:password:reset[username]"

Like;

sudo gitlab-rake "gitlab:password:reset[root]"

Check Status of Gitlab Services

Check the status of Gitlab services;

gitlab-ctl status
run: alertmanager: (pid 2380) 407s; run: log: (pid 2072) 468s
run: gitaly: (pid 2415) 406s; run: log: (pid 1507) 1209s
run: gitlab-exporter: (pid 2350) 410s; run: log: (pid 2012) 485s
run: gitlab-workhorse: (pid 2327) 411s; run: log: (pid 1917) 545s
run: grafana: (pid 2400) 407s; run: log: (pid 2283) 427s
run: logrotate: (pid 1430) 1222s; run: log: (pid 1438) 1221s
run: nginx: (pid 1951) 511s; run: log: (pid 1962) 507s
run: node-exporter: (pid 2342) 410s; run: log: (pid 1993) 493s
run: postgres-exporter: (pid 2392) 407s; run: log: (pid 2110) 461s
run: postgresql: (pid 1644) 1129s; run: log: (pid 1656) 1126s
run: prometheus: (pid 2364) 409s; run: log: (pid 2049) 475s
run: puma: (pid 1870) 560s; run: log: (pid 1878) 557s
run: redis: (pid 1465) 1216s; run: log: (pid 1476) 1215s
run: redis-exporter: (pid 2352) 409s; run: log: (pid 2037) 480s
run: sidekiq: (pid 1888) 554s; run: log: (pid 1899) 551s

Managing Gitlab Services

If you need to restart all Gitlab services;

sudo gitlab-ctl restart

You can as well use start|stop command options to control Gitlab services.

To start, stop or restart an individual component, eg nginx;

sudo gitlab-ctl start|stop|restart nginx

Accessing Gitlab Web Interface

The basic install of Gitlab on Ubuntu 24.04 is now done. All you can do now is to access the Gitlab web interface, https://server-IP-or-domain.

If UFW is running, you need to open port 443/80 to allow external access.

sudo ufw allow "Apache Full"

You can also allow access from specific IPs.

If you are not using UFW, you can also open ports using iptables.

gitlab login page ubuntu 24.04

Login to Gitlab web user interface as root user with password provided above.

Upon successful login, such an interface welcomes you.

gitlab default welcome page

Gitlab web dashboard for user root. You can access by clicking Admin Area at the bottom left;

gitlab admin area dashboard

Gitlab is now installed and setup, basically. That marks the end of our tutorial on how to install Gitlab.

What is next after Installation?

Once Gitlab is up and running, you can now proceed with the next steps outlined on the documentation page.

Steps after installing GitLab

Reference

Download and install Gitlab on Ubuntu

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
Kifarunix
Linux Certified Engineer, with a passion for open-source technology and a strong understanding of Linux systems. With experience in system administration, troubleshooting, and automation, I am skilled in maintaining and optimizing Linux infrastructure.

Leave a Comment