IZ0BEC WIKI

Install gitlab on debian 12

How to Install GitLab on Debian 12, 11 or 10
Last Updated on Monday, August 28, 2023 by Joshua James

GitLab, a comprehensive web-based Git repository manager, has become an essential tool for development teams. It offers a unified platform for software development, making collaboration, version control, and deployment more streamlined. If you’re using Debian 12 Bookworm, Debian 11 Bullseye, or Debian 10 Buster, this guide will help you understand how to install GitLab and tap into its powerful features.

Here’s why many developers prefer GitLab Community Edition:

Unified DevOps Platform: GitLab offers everything you need for software development, from the initial planning stages to the final deployment.
Collaboration Made Simple: With tools for code review, merge requests, and issue tracking, GitLab fosters teamwork and ensures everyone is on the same page.
Automated CI/CD: GitLab’s built-in CI/CD pipeline automates testing, building, and deploying code, ensuring consistent and efficient workflows.
Customizable: Tailor GitLab to your needs with a customizable user interface, project templates, and specific workflows.
Open Source: The Community Edition of GitLab is open-source, allowing developers to contribute and modify as they see fit.

While the Community Edition is feature-rich, GitLab offers Enterprise Editions for teams needing advanced analytics, enhanced security, and disaster recovery options.

After understanding GitLab’s potential, the next step is implementation. Our upcoming guide will walk you through the installation process of GitLab on your Debian system, ensuring you’re well-equipped to kickstart your projects with this robust tool.

Table of Contents

Step 1: Update Debian

Keeping your Debian operating system up to date is crucial to maintain its stability and security. To ensure that all existing packages on your Debian system are up to date, performing an update is recommended to provide the latest security updates and bug fixes, ensuring your system’s stability and reliability. You can easily update your Debian operating system by running the following command:

sudo apt update && sudo apt upgrade

Step 2: Install Required Packages for GitLab on Debian Linux

Ensuring that all dependencies for GitLab are installed is a critical step in the installation process. These dependencies are necessary components that GitLab relies on to function correctly. Fortunately, installing these dependencies is a simple process. You can easily install them by opening the terminal and running the following command:

sudo apt install curl ca-certificates apt-transport-https tzdata perl

Step 3: Import GitLab Repository on Debian Linux

By default, GitLab is not available in Debian’s default repositories. This means you must create a repository manually to install GitLab. However, GitLab provides an APT script to help with this process, making it easier for users to install the platform. With this script, you can create a GitLab repository and enable you to install GitLab using the standard APT package manager.

To download the script, enter the following command in your terminal:

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

Once you execute this command, the script will download and add the GitLab repository to your Debian system. It will also update the package list, enabling you to install GitLab using the standard APT package manager.

Example of terminal output from bash script importing GitLab onto Debian:
Screenshot of a GitLab repository imported using a bash script on Debian Linux.
PinDemonstration of importing a GitLab repository through a bash script on Debian Linux.
Step 4: Install GitLab on Debian Linux

The next step is to install GitLab. Remember that the script has already used the “apt update” command to synchronize the newly created and modified repository. With that done, you can now proceed to execute the installation command by running the following:

sudo apt install gitlab-ce

This command will install the GitLab Community Edition (CE), the free and open-source version of GitLab. The installation process may take some time, depending on your internet speed and system specifications.

Example output if GitLab installation is successful on Debian:
Terminal screenshot showing successful GitLab installation on Debian Linux.
PinTerminal confirmation of a successful GitLab installation on Debian Linux.
Step 5: Configuring GitLab on Debian Linux

To configure GitLab on Debian, several steps must be followed carefully. This section will describe the process step-by-step, including configuring the hostname, setting up the firewall, and configuring email settings.
Configure the Hostname

To access your GitLab instance, it’s crucial to configure the hostname for your GitLab server, so choose a name that’s easy to remember and access. Follow these steps to configure the hostname:

Open the GitLab configuration file using a text editor:

sudo nano /etc/gitlab/gitlab.rb

Locate the external_url setting and replace the example URL with your desired hostname:

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

Save the file and exit the text editor.
Reconfigure GitLab to apply the changes:

sudo gitlab-ctl reconfigure

Set Up the Firewall

GitLab uses port 80 for HTTP and port 443 for HTTPS by default. It’s crucial to configure your firewall to allow traffic on these ports to ensure that your GitLab instance is accessible. Follow these steps to set up the firewall:

Open the firewall configuration file using a text editor:

First, install the UFW firewall, as this does not come installed on Debian by default, with the following command:

sudo apt install ufw

Next, once the installation is complete, enable the UFW firewall with the following command:

sudo ufw enable

Open the firewall configuration file using a text editor:

sudo nano /etc/ufw/applications.d/gitlab

Copy and paste the following lines into the file:

GitLab
title=GitLab
description=GitLab application
ports=80,443/tcp

Save the file and exit the text editor.
Enable the GitLab application in the firewall:

sudo ufw app update GitLab
sudo ufw allow GitLab

Configure Email Settings

To inform users about project activities, such as new issues, merge requests, and comments, GitLab uses email notifications. Follow these steps to configure email settings:

Open the GitLab configuration file using a text editor:

sudo nano /etc/gitlab/gitlab.rb

Locate the gitlab_rails[‘smtp_enable’] setting and set it to true:

gitlab_rails'smtp_enable' = true

Add the following lines to the file to configure the SMTP server settings for your email provider, such as Gmail:

gitlab_rails'smtp_address' = "smtp.gmail.com"
gitlab_rails'smtp_port' = 587
gitlab_rails'smtp_user_name' = "example@gmail.com"
gitlab_rails'smtp_password' = "your_password"
gitlab_rails'smtp_domain' = "smtp.gmail.com"
gitlab_rails'smtp_authentication' = "login"
gitlab_rails'smtp_enable_starttls_auto' = true

Save the file and exit the text editor.
Reconfigure GitLab to apply the changes:

sudo gitlab-ctl reconfigure

It’s important to note that after executing the “gitlab-ctl reconfigure” command, you may observe that the terminal output concludes with the following message:

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.

To view the root (GitLab) password, execute the following command in your terminal:

sudo cat /etc/gitlab/initial_root_password

Example output:
Screenshot displaying GitLab's temporary password in terminal on Debian Linux.
PinTerminal view of GitLab’s temporary password post-installation on Debian Linux.

Executing this command will display the root password in the terminal. It’s crucial to keep this password secure and not share it with unauthorized users.

If you need to reset the root password, you can use the following command:

sudo gitlab-rake "gitlab:password:resetroot"

After executing this command, the root password will be reset to a random string displayed in the terminal output. It’s essential to remember that resetting the root password will invalidate all existing and personal access tokens, so users must create new ones after resetting the password.

For security reasons, it’s recommended that you change the root password to a strong and unique one as soon as possible after the initial setup and avoid using the default password. You can change the root password by logging in to the GitLab web interface, going to “User Settings”> “Account,” and selecting the “Change Password” option.
Step 6: Access GitLab User Interface on Debian Linux

Once the backend configuration is complete, it’s time to log in to and access GitLab. To achieve this, open the domain path assigned to GitLab in the configuration file.

https://gitlab.example.com

Next, use the username “root” and the password you received during installation to log in to GitLab. As mentioned in the previous section’s password printout, the guide’s password was “4zB2mbBLCcRLRAkv3qHfmSZULJ/6ocJNe2XK8zNx9nU=” in the image.

Example:
Screenshot of GitLab login page accessed via a web browser on Debian Linux.