How to Install GitLab on Debian 11

GitLab is a free and open-source DevOps platform that allows teams to iterate faster and innovate together. It is a web-based tool developed by GitLab Inc. It is very similar to GitHub and provides a Git repository manager providing wiki, issue-tracking, and continuous integration and deployment. GitLab community edition is available absolutely free for development and production environment.

In this tutorial, I will show you how to install GitLab with Nginx and Let's Encrypt SSL on Debian 11.

Prerequisites

  • A server running Debian 11 with a minimum 8GB RAM.
  • A valid domain name pointed with server IP.
  • A root password is configured on the server.

Getting Started

Before starting, it is recommended to update your package cache to the latest version. You can do it with the following command:

apt-get update -y

Once you are done, install other required dependencies using the following command:

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

Once all the required dependencies are installed, you can proceed to the next step.

Add GitLab Repository

By default, the GitLab package is not available in the Debian default repository. So you will need to add the GitLab repository to APT.

You can add it by running the following script:

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

This will add the GitLab repository to the APT source list file.

At the time of writing this article, the GitLab package is not available for Debian 11. So you will need to edit the GitLab source file and replace the Debian 11 code name with Debian 10:

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

Find the following lines:

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

Replaced them with the following lines:

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

Save and close the file then update the repository with the following command:

apt-get update -y

Install GitLab CE

You can now install the GitLab CE by running the following command:

apt-get install gitlab-ce -y

Once the GitLab has been installed, you should get the following output:

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=14-3

Configure GitLab

At this point, GitLab is installed on your system but it is not configured yet. You can configure it by editing the following file:

nano /etc/gitlab/gitlab.rb

Change the following line with your domain name:

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

Next, change the following lines to enable the Let's Encrypt SSL:

# Enable the Let's encrypt SSL
letsencrypt['enable'] = true

# This is optional to get SSL related alerts
letsencrypt['contact_emails'] = ['[email protected]']

# This example renews every 7th day at 02:00 AM
letsencrypt['auto_renew_hour'] = "2"
letsencrypt['auto_renew_minute'] = "0"
letsencrypt['auto_renew_day_of_month'] = "*/7"

Save and close the file then reconfigure the GitLab using the following command:

gitlab-ctl reconfigure

Once GitLab is reconfigured, you should get the following output containing the GitLab access password:

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!

Next, retrieve the GitLab access password using the following command:

cat /etc/gitlab/initial_root_password

You should see the following 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: WBgnk2SH4xK5FeJVsJX0Qo79IeyE5LSTGWm3EjDVEkw=

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

Access GitLab

You can now access the GitLab dashboard using the URL https://gitlab.linuxbuz.com. You will be redirected to the GitLab login page:

GitLab login

Provide your username, password and click on the Sign in button. You should see the GitLab dashboard on the following screen:

GitLab dashboard

Configure GitLab Backup

After the installation, it is recommended to take a complete backup of GitLab. You can do it with the following command:

gitlab-rake gitlab:backup:create

You can also schedule the backup by editing the /etc/crontab file:

nano /etc/crontab

Add the following line:

0   22  *  *  *   root gitlab-rake gitlab:backup:create

Save and close the file when you are finished.

Conclusion

Congratulations! you have successfully installed GitLab with Nginx and Let's Encrypt SSL on Debian 11. You can now implement GitLab in the development environment to make the software development process faster. Feel free to ask me if you have any questions.

Share this page:

1 Comment(s)