How to Install GitLab on Debian 10 (Buster)

Channel: Linux
Abstract: access your Debian server using SSH as a sudo user and invoke the following command to update the package lists on your system. $ sudo apt update Step

GitLab is a free and opensource front-end Git repository that features a Wiki and an issue tracking feature. It allows you to host Git repositories on your own server and setup DevOps platform. In this guide, we are going to install GitLab CE (Community Edition) on Debian 10 (Buster) system.

Prerequisites

Before getting started, ensure that you have the following in place:

  • An instance of Debian 10 server with SSH access.
  • Minimum of 8 GB RAM
  •  20GB of hard disk space
  • A valid domain name pointed to the IP address of the server.
  • User with sudo rights

Let’s get started with installing GitLab on Debian 10 (Buster).

Step 1) Update the System

To get started, access your Debian server using SSH as a sudo user and invoke the following command to update the package lists on your system.

$ sudo apt update
Step 2) Install GitLab dependencies

Once the update is done, install the prerequisites required as shown below.

$ sudo apt install ca-certificates curl openssh-server postfix

For the Postfix mail server, ensure that you select ‘Internet Site’ as the option for mail configuration.

Next, provide the system mail name as shown and hit ENTER on the keyboard.

Thereafter, the system will automatically complete installing all the packages and their dependencies.

Step 3) Install Gitlab CE

Up until this point, we are done with installing all the prerequisites needed to install GitLab. In this step we will proceed to install GitLab CE.

To, achieve this, first download the repository script from GitLab to the /tmp directory as shown.

$ cd /tmp
$ wget https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh

Once the script is downloaded, you need to execute it as shown.

$ sudo bash script.deb.sh

This will setup the GitLab repository ready for the installation of GitLab.

Once you are done setting up the repository, install GitLab CE as shown.

$ sudo apt install gitlab-ce

When prompted, press ‘Y’ and press ENTER on the keyboard to continue with the installation.

During the installation, you will get a notification that GitLab has not yet been configured. Additionally, the output will notify you that you have not yet configured a valid hostname for your instance.

We will go a step further and make the necessary configurations.

Step 4)  Configure Gitlab

To tune our GitLab installation, you need to edit the github.rb file. Here we will use the vim editor to open the file.

$ sudo vim /etc/gitlab/gitlab.rb

Search and locate the external_url parameter. Update the field to correspond to your domain as follows:

external_url ‘http://domain.com’

Using our test domain, this will be:

external_url 'http://crazytechgeek.info'

Next, locate the letsencrypt[‘contact_emails’] field and update it to include an email address that will be used to alert the user when Let’s Encrypt SSL certificate near its expiration date.

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

Finally, save the file and reconfigure GitLab installation as shown.

$ sudo gitlab-ctl reconfigure

The reconfiguration takes about 5 minutes to complete. Once done, you should get the notification ‘GitLab Reconfigured!

Step 5) Access Gitlab

All the configurations are now done. The only thing remaining is to access GitLab on the front-end. To achieve this, browse your domain from a web browser as shown.

http://domain.com

On your first attempt, you will be presented with the login page below. Log in using root user credentials.

You will be asked to change your password.

Once done, click on ‘change your password’ option and hit ENTER. This ushers you to the GitLab dashboard as shown.

Step 6) Secure Gitlab using Let’s Encrypt SSL Certificate

Let’s Encrypt is a free security certificate by Lets Encrypt authority that allows you to secure your website. GitLab configuration supports Let’s Encrypt and, in this step, we will configure our Gitlab instance to use Let’s Encrypt SSL for secure connections.

Head back to the gitlab.rb file

 $ sudo vim /etc/gitlab/gitlab.rb

Edit the following parameters as shown.

letsencrypt['enable'] = true
letsencrypt['auto_renew'] = true

The first line allows Let’s Encrypt to be configured and the second line sets the renewal of the certificate to be automatic.

Along with that, you can define the auto renewal hour and day of the month as follows:

letsencrypt['auto_renew_hour'] = 5
letsencrypt['auto_renew_day_of_month'] = "*/6"

Also, set the URL to use HTTPS protocol instead of HTTP.

external_url 'https://crazytechgeek.info'

Save the changes and exit the config file.  To make above changes into the effect, once again run the below command .

$ sudo gitlab-ctl reconfigure

To verify that everything went according to plan, invoke the command:

$ sudo gitlab-rake gitlab:check

Reload the browser and notice that the URL to your server’s instance is now secured using Let’s Encrypt SSL certificates.

This wraps up our guide for today. In this guide, we showed you how to install and configure GitLab on Debian 10.

Ref From: linuxtechi

Related articles