Install GitLab on Debian 12 Bookworm | Best Manager Tool for Git Repos
In this comprehensive guide, we will delve into the process of installing GitLab on Debian 12 Bookworm. GitLab stands out as a robust and versatile management platform designed specifically for Git repositories. It offers a range of features catering to both individual developers and large organizations. There are two distinct versions of GitLab available:
- GitLab Community Edition (CE): This is the free and open-source version, suitable for smaller teams and individual developers.
- GitLab Enterprise Edition (EE): This is the paid version offering additional features and support, ideal for larger organizations with more complex needs.
You can follow the steps below to Install GitLab on Debian 12 Bookworm on the Orcacore website. We will install the community edition.
Before we begin, ensure you have the following prerequisites in place:
- Access to your Debian 12 server as a non-root user with sudo privileges.
- A basic firewall configured for security. You can refer to this guide on Initial Server Setup with Debian 12 Bookworm at Orcacore for detailed instructions.
- A domain name pointed to your server’s IP address. This is crucial for accessing your GitLab instance via a web browser.
With these prerequisites met, let’s proceed with the installation steps to Install GitLab on Debian 12 Bookworm.
Step 1. Install GitLab Dependencies on Debian 12
First, it’s essential to update your local package index to ensure you have the latest package information. Execute the following command:
sudo apt update
Next, install the necessary dependencies required for GitLab to function correctly. This includes packages like ca-certificates
, curl
, openssh-server
, postfix
, tzdata
, and perl
. Use the following command:
sudo apt install ca-certificates curl openssh-server postfix tzdata perl
During the postfix
installation, you will be prompted to select a configuration type. Choose Internet Site. On the subsequent screen, enter your server’s domain name. This configuration determines how the system will send email notifications.
Step 2. Download GitLab Installation Script on Debian Linux
To simplify the installation process, we will use an installation script provided by GitLab. First, navigate to the /tmp
directory:
cd /tmp
Then, use the following curl command to download the GitLab installation script onto your Debian 12 server:
sudo curl -LO https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh
After the download is complete, run the installer script using the following command:
sudo bash /tmp/script.deb.sh
Upon successful execution, you will receive the following output, confirming that the GitLab repository has been set up:
**Output**
The repository is setup! You can now install packages.
Step 3. GitLab CE Installation on Debian 12 Terminal
With the repository configured, you can now proceed with the installation of GitLab CE. Execute the following command:
sudo apt install gitlab-ce
The installation process may take some time, depending on your server’s resources. Once completed, you will see output similar to the following:
**Output**
*. *.
*** ***
***** *****
.****** *******
******** ********
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,,
,*,.
_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __
/ /_/ / / /_/ /___/ /_/ / /_/ /
____/_/__/_____/__,_/_.___/
Thank you for installing GitLab!
Step 4. Configure UFW Firewall for GitLab
This step assumes that you have already enabled the UFW firewall, as mentioned in the prerequisites. To allow access to GitLab through the firewall, you need to adjust the rules. Run the following commands:
# sudo ufw allow http
# sudo ufw allow https
# sudo ufw allow OpenSSH
To apply the new firewall rules, reload the firewall:
sudo ufw reload
Step 5. Edit GitLab Configuration File on Debian 12
Now, you need to update the GitLab configuration file to reflect your server’s specific settings. Open the file with your preferred text editor. Here, we’re using the vi editor:
sudo vi /etc/gitlab/gitlab.rb
Locate the external_url
configuration line and update it to your domain name. Also, ensure that you change http
to https
to automatically redirect users to the secure site protected by the Let’s Encrypt certificate:
...
external_url 'https://your_domain'
...
Next, find the following line and uncomment it by removing the #
symbol. Then, set your email address:
...
letsencrypt['contact_emails'] = ['olivia@example.com']
...
Save the changes and close the file.
Command To Initialize GitLab
To apply the configuration changes, reconfigure GitLab using the following command:
sudo gitlab-ctl reconfigure
This process will initialize GitLab, using the information it gathers about your server. It will also configure a Let’s Encrypt certificate for your domain. This process can take some time.
Once the reconfiguration is complete, you will see the following output:
**Output**
gitlab Reconfigured!
Step 6. Access GitLab Web Interface
You can now continue the GitLab configuration through the web interface. Open your web browser and enter your domain name:
https://your_domain
This will display the GitLab Community Edition login page.
Note: GitLab generates an initial secure password for you. You can access it as an administrative sudo user:
sudo cat /etc/gitlab/initial_root_password
You should see something like this:
Password: your-initial-root-password
On the GitLab login page, enter root as the username and your initial password as the password, then click Sign in.
You will be signed into the GitLab application and taken to a landing page that prompts you to begin adding projects.
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
GitLab includes a scheduled task that automatically renews Let’s Encrypt certificates after midnight every fourth day, with the exact minute based on your external_url
.
You can customize these settings by modifying the GitLab configuration file:
sudo vi /etc/gitlab/gitlab.rb
Find the following lines in the file, remove the #
, and update them:
letsencrypt['auto_renew'] = true
letsencrypt['auto_renew_hour'] = "12"
letsencrypt['auto_renew_minute'] = "30"
letsencrypt['auto_renew_day_of_month'] = "*/7"
...
This configuration will renew your certificates every 7th day at 12:30. You can adjust the date and time as desired.
To disable auto-renewal, set letsencrypt['auto_renew']
to false
:
...
letsencrypt['auto_renew'] = false
...
Save the changes and close the file.
For more detailed information, refer to the GitLab Documentation.
Conclusion
You have successfully learned to Install GitLab on Debian 12 Bookworm. You have also learned how to set up a scheduled task to renew Let’s Encrypt certificates for GitLab.
Hope you enjoy it. You may also like these articles:
Install a Deb File by dpkg or by APT on Debian
Install OpenNMS on Debian 12 Bookworm
Alternative Solutions for Installing GitLab on Debian 12 Bookworm
While the above method using the official GitLab repository is recommended, here are two alternative approaches for Install GitLab on Debian 12 Bookworm:
1. Using Docker:
Docker provides a containerized environment, simplifying the installation and management of GitLab. This method isolates GitLab and its dependencies from the host system, preventing potential conflicts.
-
Explanation:
- Docker containers encapsulate an application and all its dependencies, ensuring consistency across different environments.
- Using Docker Compose allows defining and managing multi-container Docker applications.
-
Steps:
-
Install Docker and Docker Compose:
sudo apt update sudo apt install docker.io docker-compose
-
Create a
docker-compose.yml
file:Create a directory for your GitLab configuration and within it, create a
docker-compose.yml
file. Here’s a basic example:version: '3.6' services: gitlab: image: 'gitlab/gitlab-ce:latest' restart: always hostname: 'gitlab.example.com' # Replace with your domain environment: GITLAB_OMNIBUS_CONFIG: | external_url 'https://gitlab.example.com' # Replace with your domain gitlab_rails['gitlab_shell_ssh_port'] = 2224 ports: - '80:80' - '443:443' - '2224:22' volumes: - '/srv/gitlab/config:/etc/gitlab' - '/srv/gitlab/logs:/var/log/gitlab' - '/srv/gitlab/data:/var/opt/gitlab'
Note: Replace
gitlab.example.com
with your actual domain name. Also, adjust the volumes to suit your storage needs. Port 2224 is used to avoid conflict with the host system’s SSH. -
Start GitLab:
Navigate to the directory containing the
docker-compose.yml
file and run:sudo docker-compose up -d
This command will download the GitLab image and start the container in detached mode.
-
Access GitLab:
Once the container is running, access GitLab through your web browser using the configured domain name (e.g.,
https://gitlab.example.com
).
-
2. Using a Pre-built Virtual Machine Image:
Another alternative is to download a pre-built virtual machine (VM) image containing GitLab. This approach provides a ready-to-use GitLab instance, simplifying the setup process.
-
Explanation:
- VM images are pre-configured environments that can be easily imported into virtualization software.
- This method avoids manual installation and configuration steps, making it ideal for quick deployments.
-
Steps:
-
Download a GitLab VM Image:
- Search for pre-built GitLab VM images on platforms like Bitnami or TurnKey Linux. Make sure the image is compatible with Debian or Ubuntu.
- Download the VM image in a format suitable for your virtualization software (e.g., OVA for VirtualBox or VMware).
-
Install Virtualization Software (if not already installed):
- Popular options include VirtualBox and VMware Workstation.
- Install the chosen virtualization software on your Debian 12 Bookworm system.
-
Import the VM Image:
- Open your virtualization software and import the downloaded VM image.
- Configure the VM settings, such as memory and network adapter.
-
Start the VM:
- Start the imported VM.
- Once the VM is running, obtain its IP address.
-
Access GitLab:
- Open your web browser and enter the VM’s IP address.
- Follow the instructions provided by the VM image vendor to access and configure your GitLab instance. Typically, the default username and password are provided in the image’s documentation.
-
These alternative methods offer different approaches to Install GitLab on Debian 12 Bookworm, catering to various preferences and requirements. Docker provides isolation and portability, while VM images offer a quick and easy setup experience. Choose the method that best aligns with your technical expertise and deployment goals.