How to Install & Configure GitLab on Debian 11 Bullseye

GitLab is a free and open-source web-based code repository for collaborative software development for DevOps, written in Ruby and Go programming languages. GitLab’s main motto is “Bring velocity with confidence, security without sacrifice, and visibility into DevOps success.” It is quite a popular alternative to GitHub providing wiki, issue-tracking, and continuous integration and deployment pipeline features, using an open-source license, developed by GitLab Inc.

In the following tutorial, you will learn how to install GitLab on your Debian 11 Bullseye system, along with how to get started by logging in with root so you can begin setting up GitLab to your liking or for your team’s requirements.

Prerequisites

  • Recommended OS: Debian 11 Bullseye
  • User account: A user account with sudo privilages or root access (su command).

Updating Operating System

Update your Debian 11 Bullseye operating system to make sure all existing packages are up to date:

sudo apt update && sudo apt upgrade

Root or Sudo Access

By default, when you create your account at startup with Debian compared to other distributions, it does not automatically receive sudoers status. You must either have access to the root password to use the su command or visit our tutorial on How to Add a User to Sudoers on Debian.

Install Dependencies for GitLab

Before you install GitLab on your Debian 11 Bullseye operating system, you will need to install the dependencies for it so that you can install and operate GitLab.

Open your terminal and execute the following command:

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

Advertisement


Create & Import GitLab Repository

By default, GitLab does not come packaged in Debian 11 default repositories. This means you will need to create one manually. However, GitLab has created a handy APT script for you to download and execute to aid you in this task.

Download the GitLab APT script using the curl command:

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

Example output from the script:

How to Install & Configure GitLab on Debian 11 Bullseye

Now, before you continue, you will need to modify the repository GitLab created. This is due to Debian 11 Bullseye being newly released, and they have not made a repository for it yet. However, you can still install GitLab and receive updates by changing the repository source to Debian 10 Buster.

To do this, first, open up the “gitlab_gitlab-ce.list” file using any text editor:

sudo nano /etc/apt/sources.list.d/gitlab_gitlab-ce.list

Next, replace the two repository lines from “bullseye main” to “buster main.”

Example from:

deb https://packages.gitlab.com/gitlab/gitlab-ce/debian/ bullseye main
deb-src https://packages.gitlab.com/gitlab/gitlab-ce/debian/ bullseye main

Example to:

deb https://packages.gitlab.com/gitlab/gitlab-ce/debian/ buster main
deb-src https://packages.gitlab.com/gitlab/gitlab-ce/debian/ buster main

Graphical example:

How to Install & Configure GitLab on Debian 11 Bullseye

Once done, CTRL+O then exits the file with CTRL+X.

Now run the apt update command to verify and sync the new repository.

sudo apt update

Note, this may change in the future, and the tutorial will be updated when this occurs.

Install Gitlab

The next part of the tutorial is to install GitLab, and you should have already used the apt update command to sync the newly created and modified repository. Now execute the install command using the following:

sudo apt install gitlab-ce

Example output and dependencies to be installed along GitLab:

How to Install & Configure GitLab on Debian 11 Bullseye

Type “Y,” then press the “ENTER KEY” to proceed with the installation. Note that the installation size is 2.5GB, so slow Internet connections could wait a while for the download and installation to complete.

Once the installation is complete, you should get the following output in your terminal.

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 min
ute survey:
https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnib
us&release=14-3

Processing triggers for man-db (2.9.4-2) ...
Processing triggers for ufw (0.36-7.1) ...

Advertisement


How to Configure GitLab

With GitLab installed, you can now configure SSL, the domain name or subdomain name passwords, and much more. The tutorial will go over the basic setup options that should be done. However, you can do alternative settings to those listed below.

First, open the “gitlab.rb” configuration file using any text editor:

sudo nano nano /etc/gitlab/gitlab.rb

The first setting will be setting the domain, navigating down to line 36, and finding the following.

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

Change this to your subdomain name.

Example:

How to Install & Configure GitLab on Debian 11 Bullseye

Next, set up TLS/SSL with Let’s Encrypt, which starts on line 2297.

By default, all settings are commented out with “#.” You will need to uncomment the following lines.

 letsencrypt['enable'] = true
 letsencrypt['contact_emails'] = ['youremail@yourdomain.com']
 letsencrypt['auto_renew'] = true
 letsencrypt['auto_renew_hour'] = 4
 letsencrypt['auto_renew_day_of_month'] = "*/4"
 letsencrypt['auto_renew_log_directory'] = '/var/log/gitlab/lets-encrypt'

Example:

How to Install & Configure GitLab on Debian 11 Bullseye

Once done, CTRL+O then exits the file with CTRL+X.

Now run the reconfigure command as follows.

sudo gitlab-ctl reconfigure

In the end, you will receive the following message in your terminal.

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.

Running handlers complete
Chef Infra Client failed. 218 resources updated in 41 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.

To view the root (GitLab) password, run the following command.

cat /etc/gitlab/initial_root_password

Example output:

# 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: SGGg/WQ9+N1JdgouIbPftla+Kt8Qcyr+HL5oJfRbBmM=

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

As above, you can see the password is “SGGg/WQ9+N1JdgouIbPftla+Kt8Qcyr+HL5oJfRbBmM=” and that this file will be automatically deleted in 24 hours.

How to Access GitLab

Now that the backend is set, it is time to log in and see your GitLab.

First, open up the domain path where GitLab was assigned in the configuration file.

Example:

https://gitlab.example.com

Next, sign in using the username “root” and the password you received, which in the tutorial case was “SGGg/WQ9+N1JdgouIbPftla+Kt8Qcyr+HL5oJfRbBmM=”.

Example:

How to Install & Configure GitLab on Debian 11 Bullseye

You are successfully logged in as the root account, and you will hit the default landing page.

Example:

How to Install & Configure GitLab on Debian 11 Bullseye

From here, you can proceed to set up and configure GitLab to suit your requirements or your team. One of the first things you should do is go to the admin section and configure the security, such as 2FA, changing root passwords, and much more before adding any team members. This can all be found by clicking on the Menu > Admin in the top left-hand corner of the page.

Example:

How to Install & Configure GitLab on Debian 11 Bullseye

Advertisement


Create Cronjob for GitLab Auto Backup

By default, there are no backups created or configured. This should be set using a cronjob, and the frequency set a value that suits your availability of resources and frequency of GitLab changes.

First, open your crontab.

sudo crontab -e

Next, add the following example and modify the time to suit your needs. If you are a bit unsure of the timing, then visit crontab.guru.

00 */3 * * *   root gitlab-rake gitlab:backup:create

The above creates a backup every 3 hours exactly.

Example:

How to Install & Configure GitLab on Debian 11 Bullseye

Once done, CTRL+O then exits the file with CTRL+X.

Alternatively, you can run the task at any time manually by executing the following command.

sudo gitlab-rake gitlab:backup:create

Once the backup has been completed, you will get the following message in your terminal.

Backup task is done.

Comments and Conclusion

In the following tutorial, you have learned how to install GitLab on Debian 11 Bullseye, set up TLS/SSL with Lets Encrypt, and create a backup cron job. Overall, self-hosting GitLab can be significant than relying on a third party if privacy is a significant concern and can make development easier and quicker.

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x