How to Install Gitlab On Debian 11

GitLab is a web-based DevOps lifecycle tool that provides a Git repository manager providing wiki, issue-tracking, and continuous integration and deployment pipeline features, using an open-source license, developed by GitLab Inc.

Update the system.

apt update

apt upgrade

Install required dependencies,

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

Add Gitlab Repository using below command,

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

At the time of making this guide, the GitLab package is not available for Debian 11. You will need to edit the GitLab source file and replace the Debian 11 (Bullseye) code name with Debian 10 (Buster),

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 and update the repository using the below command,

apt-get update 

Install GitLab CE

apt-get install gitlab-ce -y

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

Configure GitLab

Once the installation is complete, we will configure the GitLab to our requirements. Below are the edits that can be done,

nano /etc/gitlab/gitlab.rb

Replace the following line with your domain name,

external_url 'https://Your_Domain_Name'

Replace/Edit 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'] = ['youremail@mail.com']

# This example renews every 1st day at 01:00 AM
letsencrypt['auto_renew_hour'] = "1"
letsencrypt['auto_renew_minute'] = "0"
letsencrypt['auto_renew_day_of_month'] = "*/1"

Save and close the file.

Let us update the repository now with the below command,

gitlab-ctl reconfigure

Output:

   Recipe: registry::enable
  * runit_service[registry] action restart (up to date)
Recipe: nginx::enable
  * execute[reload nginx] action run
    - execute gitlab-ctl hup nginx
Recipe: letsencrypt::enable
  * ruby_block[display_le_message] action run
    - execute the ruby block display_le_message
Recipe: monitoring::grafana
  * runit_service[grafana] action restart (up to date)

Running handlers:
Running handlers complete
Chef Infra Client finished, 26/861 resources updated in 02 minutes 08 seconds

Warnings:
Let's Encrypt is enabled, but external_url is using http

gitlab Reconfigured!

Retrieve the GitLab password using following command,

cat /etc/git/initial_root_password

Output:

root@server:~# 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.
#
#          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: 0XcTcmq8Wvc53VcBMMzrgbtBHZ7GXdj6BISapBWNjYQ=

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

Open a browser and type the following address and You will be redirected to the GitLab login page,

Replace Your_Domain_Name with Actual Domain name

https://Your_Domain_Name 

image

image

Done.