How to install and set up Gitlab CE Server on Debian 11

GitLab allows you to host an on-premise Git repository that can be accessed from either your local LAN or (if you have an available public IP address) from outside your company. GitLab is an open-source repository manager based on Rails developed by GitLab Inc. It is a web-based git repository manager that allows your team to collaborate on coding, testing, and deploying applications. GitLab provides several features, including wikis, issue tracking, code reviews, and activity feeds.

In this guide, we will install the GitLab CE on the Debian 11. We will install the GitLab CE using the ā€˜omnibusā€™ package provided by GitLab.

Prerequisites

  • Updated Debian 11 server
  • Access to the internet
  • Ensure that your server is at lease 4GB of RAM with more than 20GB of disk space and 2 CPUs

Table of Content

  1. Ensure that the server packages are up to date
  2. Installing and configuring the necessary dependencies
  3. Add the GitLab package repository and install the package
  4. Fix for the GitLab ā€œUnable to locate package gitlab-ceā€ on Debian 11
  5. Configuring Gitlab CE
  6. Accessing Gitlab CE

1. Ensure that the server packages are up to date

Before proceeding let us update our Centos 8 server using this command:

sudo apt update
sudo apt update -y

Install common packages that will be essential

sudo apt install -y vim

2. Install and configure the necessary dependencies

Before proceeding letā€™s ensure that the pakages needed are installed. Use this command:

sudo apt-get install -y curl openssh-server ca-certificates perl

Next, install Postfix to send notification emails. If you want to use another solution to send emails please skip this step andĀ configure an external SMTP serverĀ after GitLab has been installed.

sudo apt install -y postfix

During Postfix installation a configuration screen may appear. Select ā€˜Internet Siteā€™ and press enter. Use your serverā€™s external DNS for ā€˜mail nameā€™ and press enter. If additional screens appear, continue to press enter to accept the defaults.

3. Add the GitLab package repository and install the package

Add the GitLab package repository.

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

Next, install the GitLab package. Make sure you have correctlyĀ set up your DNS, and changeĀ https://gitlab.citizix.comĀ to the URL at which you want to access your GitLab instance. Installation will automatically configure and start GitLab at that URL.

ForĀ https://Ā URLs, GitLab will automaticallyĀ request a certificate with Letā€™s Encrypt, which requires inbound HTTP access and aĀ valid hostname. You can alsoĀ use your own certificateĀ or just useĀ http://Ā (withoutĀ s).

If you would like to specify a custom password for the initial administrator user (root), check theĀ documentation. If a password is not specified, a random password will be automatically generated.

sudo apt update
sudo EXTERNAL_URL="https://gitlab.citizix.com" apt install gitlab-ce

4. Fix for the GitLab ā€œUnable to locate package gitlab-ceā€ on Debian 11

If the above fail with

Unable to locate package gitlab-ce, a workaroud is using the debian 10 repos.

Edit the repo file

sudo vim /etc/apt/sources.list.d/gitlab_gitlab-ce.list

Update the content as follows

deb https://packages.gitlab.com/gitlab/gitlab-ce/debian/ buster main
deb-src https://packages.gitlab.com/gitlab/gitlab-ce/debian/ buster main

Now you can update and install gitlab ce

<meta charset="utf-8">sudo apt update
sudo EXTERNAL_URL="https://gitlab.citizix.com" apt install gitlab-ce

5. Configuring Gitlab CE

Now that gitlab is successfully installed, letā€™s configure it. The main configuration file can be found in the file/etc/gitlab/gitlab.rb. Open the file (vim&nbsp;/etc/gitlab/gitlab.rb) and confirm that the external url is set as defined during installation:

external_url 'http://gitlab.citizix.com'

Save & and run the reconfiguration script

sudo gitlab-ctl reconfigure

Wait for the configuration script to finish. You should see something similar to this:

Recipe: monitoring::alertmanager
  * runit_service[alertmanager] action restart (up to date)
Recipe: monitoring::postgres-exporter
  * runit_service[postgres-exporter] action restart (up to date)
Recipe: monitoring::grafana
  * runit_service[grafana] action restart (up to date)

Running handlers:
Running handlers complete
Chef Infra Client finished, 189/1108 resources updated in 02 minutes 28 seconds
gitlab Reconfigured!

6. Accessing Gitlab CE

Once the configuration is complete, Gitlab CE is available in the URL provided (In my case http://gitlab.citizix.com. Ensure that the DNS entry for the URL is pointing to the server then access that url in the browser. You should be redirected to the login page as shown below:

Gitlab CE Sign in Page

Unless you provided a custom password during installation, a password will be randomly generated and stored for 24 hours inĀ /etc/gitlab/initial_root_password. Use this password with usernameĀ rootĀ to login.

sudo cat /etc/gitlab/initial_root_password

Once logged in you can use the gitlab server to create and manange projects and repositories.

Conclusion

Congratulations, you now have your local GitLab up and running.Ā  You can now use your Gitlab CE Server to manage repositories and projects.

Have fun!

comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy