Steps To Install GitLab on Debian 12 Bookworm

In this guide, we want to teach you to Install and Access the GitLab CE Web interface on Debian 12 Bookworm. GitLab is a management platform for Git repositories. There are two versions of GitLab:

  • The hosted commercial product is offered in a software-as-a-service (SaaS) format
  • GitLab CE (Community Edition)

You can follow the steps below to set up GitLab CE on your Debian 12.

Steps To Install and Access GitLab CE on Debian 12 Bookworm

To set up GitLab CE, you must have access to your server as a non-root user with sudo privileges and set up a basic firewall. To do this, you can follow this guide on Initial Server Setup with Debian 12 Bookworm.

Also, you need a domain name that is pointed to your server’s IP address.

Then, follow the steps below to complete this guide.

Step 1 – Install GitLab Depedencies on Debian 12

First, you need to update your local package index with the following command:

sudo apt update

Then, use the following command to install GitLab dependencies:

sudo apt install ca-certificates curl openssh-server postfix tzdata perl

For the postfix installation, select Internet Site when prompted. Enter your server’s domain name on the next screen to configure how the system will send mail.

Step 2 – Download GitLab Installation Script on Debian Linux

First, switch to your /tmp directory:

cd /tmp

Then, use the following curl command to download the GitLab installation script on Debian 12:

sudo curl -LO https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh

Next, run the installer script by using the command below:

sudo bash /tmp/script.deb.sh

When you are done, you will get the following output:

Output
The repository is setup! You can now install packages.

Step 3 – GitLab CE Installation on Debian 12 Terminal

At this point, you can install the GitLab CE on Debian 12 with the following command:

sudo apt install gitlab-ce
Output

       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.



     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/


Thank you for installing GitLab!

Step 4 – Configure UFW Firewall for GitLab

At this point, we assumed that you had enabled the UFW firewall from the requirements.

To adjust the firewall rules, run the commands below:

# sudo ufw allow http
# sudo ufw allow https
# sudo ufw allow OpenSSH

To apply the new rules, reload the firewall:

sudo ufw reload

Step 5 – Edit GitLab Configuration File on Debian 12

At this point, you need to update the GitLab configuration file. To do this, open the file with your favorite text editor, we use vi editor:

sudo vi /etc/gitlab/gitlab.rb

Find the external_url configuration line and update it to your domain and make sure to change http to https to automatically redirect users to the site protected by the Let’s Encrypt certificate.

...
external_url 'https://your_domain'
...

Also, find the line below and uncomment it by removing the “#” and setting your email address:

...
letsencrypt['contact_emails'] = ['[email protected]']
...

When you are done, save and close the file.

Command To Initialize GitLab

Now use the command below to reconfigure GitLab on Debian 12:

sudo gitlab-ctl reconfigure

This will initialize GitLab using the information it can find about your server. The process will also configure a Let’s Encrypt certificate for your domain.

This will take some time to complete.

When you are done, you will get the following output:

Output
gitlab Reconfigured!

Step 6 – Access GitLab Web Interface

At this point, you can continue your GitLab configuration on Debian 12 from the Web interface. To do this, type your domain name in your web browser as shown below:

https://your_domain

You will see the GitLab Community Edition Login page.

Note: GitLab generates an initial secure password for you. It is stored in a folder that you can access as an administrative sudo user:

sudo cat /etc/gitlab/initial_root_password

You should see something similar to this:

Password: your-initial-root-password

Now from your GitLab login page enter root as the username and your initial password as your password and click Sign in.

Gitlab login page

You will be signed in to the GitLab application and taken to a landing page that prompts you to begin adding projects.

GitLab App

From here you can update your password, adjust your profile settings, change your account name, add an SSH key to your account, etc.

Step 7 – Renew Let’s Encrypt Certificates for GitLab on Debian 12

By default, GitLab has a scheduled task set up to renew Let’s Encrypt certificates after midnight every fourth day, with the exact minute based on your external_url.

You can change these settings by modifying the GitLab configuration file:

sudo vi /etc/gitlab/gitlab.rb

Then, find the following lines in the file and remove the # and update it with the following:

letsencrypt['auto_renew'] = true
letsencrypt['auto_renew_hour'] = "12"
letsencrypt['auto_renew_minute'] = "30"
letsencrypt['auto_renew_day_of_month'] = "*/7"
...

This will renew your certificates every 7th day at 12:30. You can change it to your desired date.

Also, you can disable auto-renewal by setting the letsencrypt[‘auto_renew’] to false:

...
letsencrypt['auto_renew'] = false
...

When you are done, save and close the file.

For more information, you can visit GitLab Documentation.

Conclusion

At this point, you have learned to Install and Access the GitLab Web interface on Debian 12 Bookworm. Also, you have learned to set up a scheduled task to renew the Let’s Encrypt certificates for GitLab.

Hope you enjoy it. You may like these articles:

Install a Deb File by dpkg or by APT on Debian

Install OpenNMS on Debian 12 Bookworm

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

POPULAR TAGS

Most Popular