How To Install GitLab on Debian 11

In this tutorial, we want to teach you How To Install and Configure GitLab on Debian 11.

GitLab is an open-source code repository and collaborative software development platform for large DevOps and DevSecOps projects. GitLab is free for individuals.

It offers a location for online code storage and capabilities for issue tracking and CI/CD. The repository enables hosting different development chains and versions and allows users to inspect previous code and roll back to it in the event of unforeseen problems.

GitLab is a competitor to GitHub, the code repository that hosts Linus Torvalds Linux kernel development, among many other projects. Because GitLab is developed on the same Git basis of version control, it functions very similarly for source code management.

Steps To Install and Configure GitLab on Debian 11

To install GitLab, you must log in to your server as a non-root user with sudo privileges and set up a basic firewall. To do this, you can follow our guide on Initial Server Setup with Debian 11.

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

Now follow the steps below to complete this guide.

Install GitLab on Debian 11

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.

Download GitLab Installation Script

First, switch to your /tmp directory:

cd /tmp

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

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.

Now you can install the GitLab application on Debian 11:

sudo apt install gitlab-ce
Output
It looks like GitLab has not been configured yet; skipping the upgrade script.

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



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


Thank you for installing GitLab!

Configure Firewall Rules on Debian 11

At this point, you need to ensure that your firewall rules are permissive enough to allow web traffic. We assumed that you had enabled 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

Configure GitLab on Debian 11

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

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.

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

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!

Access GitLab Web Interface

At this point, you can continue your GitLab configuration on Debian 11 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 vi /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 Dashboard Debian

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

Renew Let’s Encrypt Certificates for GitLab on Debian 11

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.

Conclusion

At this point, you have learned to Install and Configure GitLab on Debian 11.

Hope you enjoy it.

You may be like these articles:

How To Upgrade PHP Version on Debian 11

Check Installed Linux Kernel in Command Line

How To Install AnyDesk on Debian 11

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!