YouTube Icon

Code Playground.

How to Install and Configure GitLab on Ubuntu 18.04


How to Install and Configure GitLab on Ubuntu 18.04

GitLab is an online open-source Git storehouse director written in Ruby including wiki, issue the executives, code audit, observing, and ceaseless coordination and arrangement. It empowers engineers to make, audit, and send their ventures. 

There are three unique releases of GitLab accessible, Community Edition (CE), Enterprise Edition (EE), and a GitLab-facilitated adaptation. 

GitLab is the main decision in the event that you need to move away from GitHub . It can import activities and issues from various sources including GitHub, which makes the movement cycle bother free. The GitLab interface is all around planned, perfect, natural and near GitHub's regarding client experience and usefulness. 

There are a few different ways to introduce GitLab relying upon the necessary use case. This instructional exercise covers the means fundamental for introducing and designing GitLab (CE) on a Ubuntu 18.04 framework utilizing the Omnibus bundles. 


This instructional exercise accepts that you have a new Ubuntu 18.04 establishment. As indicated by the GitLab prerequisites page , it is prescribed to utilize a worker with: 

  • at any rate 4GB of RAM memory . 
  • 2 CPU centers. 
  • at any rate 2GB of trade space . 

(discretionary) Domain or subdomain highlighting the worker IP address. 

For an extra layer of security it is prescribed to set up a fundamental firewall. You can follow the means in our How To Set Up a Firewall with UFW on Ubuntu 18.04 guide. 

Prior to beginning with the instructional exercise, ensure you are signed in as a client with sudo advantages . 

Installing Required Dependencies

Revive the neighborhood bundle record and introduce the conditions with the accompanying orders: 

sudo apt update
sudo apt install curl openssh-server ca-certificates

With the goal for GitLab to have the option to send warning messages, you can either introduce and utilize Postfix or utilize some conditional mail administration, for example, SendGrid, MailChimp, MailGun or SES in which case you can avoid the accompanying advance and design [GitLab SMTP settings] ( after the establishment is finished. 

Run the accompanying orders to introduce Postfix on your Ubuntu worker: 

debconf-set-selections <<< "postfix postfix/mailname string $(hostname -f)"
debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'"
sudo apt install postfix

For more definite data about how to arrangement your own mail worker check this arrangement . 

Installing GitLab

GitLab establishment is a lovely straight forward cycle. We will introduce the GitLab CE bundle utilizing the well-suited bundle supervisor. 

Start by adding the GitLab storehouse to your framework sources list utilizing the accompanying twist order : 

curl | sudo bash

When the storehouse is empowered introduce the GitLab bundle by running the accompanying order. 

sudo apt install gitlab-ce

The establishment cycle may take some time and after an effective establishment, you will see the accompanying yield: 

Thank you for installing GitLab!

Adjusting the Firewall Rules 

The guide about setting up an essential firewall is connected in the requirements area. To have the option to get to the GitLab interface we need to open ports 80 and 443: 

sudo ufw allow OpenSSH
sudo ufw allow http
sudo ufw allow https

To be certain that the necessary ports are open you can check the status of the firewall with: 

sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
80/tcp                     ALLOW       Anywhere
443/tcp                    ALLOW       Anywhere
OpenSSH                    ALLOW       Anywhere
80/tcp (v6)                ALLOW       Anywhere (v6)
443/tcp (v6)               ALLOW       Anywhere (v6)
OpenSSH (v6)               ALLOW       Anywhere (v6)

Set the GitLab URL

Prior to getting to the GitLab web interface we need to set the URL on which GitLab will be reachable. Open Gitlab's arrangement record and roll out the accompanying improvements: 

sudo nano /etc/gitlab/gitlab.rb

Close to the highest point of the arrangement document, you will see a line beginning with external_url. Change the incentive to coordinate your area/subdomain or IP address. In the event that you have space use https and on the off chance that you need to get to the GitLab interface through your worker IP address use http. 


external_url ''

Next quest for "How about we Encrypt mix", uncomment the line beginning with letsencrypt['enable'] and set it to valid. Alternatively on the off chance that you need to get messages from Let's Encrypt concerning your space uncomment the line beginning with letsencrypt['contact_emails'] and add your email address. 

In the event that you set the external_url to an IP address, at that point don't empower Let's Encrypt incorporation. 


letsencrypt['enable'] = true
letsencrypt['contact_emails'] = [''] # This should be an array of email addresses to add as contacts

At long last, save and close the document and run the accompanying order to reconfigure Gitlab: 

sudo gitlab-ctl reconfigure

The order will reconfigure your GitLab settings and produce a free Let's scramble SSL endorsement. 

Configure GitLab through the Web Interface

Since you have arranged the GitLab URL you can begin with the underlying design through the GitLab web interface. 

Dispatch your internet browser and explore to:

1. Setting administrative account password

The first occasion when you access the web interface you'll be incited to set the secret word for the regulatory record. 

Enter a safe secret word and snap on the Change your secret word button when you are done. 

You will be diverted to the login page: 

The default regulatory record username is root. Later in this instructional exercise, we will tell you the best way to change the username. 

  • Username: root 
  • Secret key: [the secret key you have set] 

When you enter the login certifications and snap the Sign in catch you will taken to the GitLab Welcome page. 

2. Editing User profile 

The principal thing you will need to do is to alter your client profile. Snap on the client symbol (upper-right corner) and starting from the drop menu, select Settings: 

Here you can change your Name, Email, and other profile data and settings. Roll out the improvements as per your preferring.  

Whenever you are done tap on the Update Profile settings button and in no time you will get an affirmation email to the location you gave. To affirm your record adhere to the directions gave in the email. 

3. Changing Username

To get to the Profile page, click on the Account connect from the left-hand vertical route menu. 

As you definitely know the default username of the main authoritative record is root. To transform it simply type your new username and snap on the Update username button. 

On this screen, you can likewise empower two-factor confirmation. 

Whenever you will sign in to your GitLab dashboard you should enter the new username. 

4. Adding SSH Key

To have the option to push your nearby git changes to the GitLab worker you to add your SSH public key to your GitLab account. 

In the event that you as of now have a SSH key pair made on your neighborhood framework you can show the public key by composing: 

cat ~/.ssh/

The yield should look something like the accompanying: 

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDd/mnMzHwjUzK8g3ldfsfRpJuC16mhWamaXRk8ySQrD/dzpbRLfDnZsLxCzRoq+ZzFHGwcQlJergtergdHGRrO8FE5jl3IWRRp+mP12qYw==

In the event that the order above prints No such record or catalog it implies that you don't have a SSH key pair produced on your machine. 

To create another SSH key pair utilize the accompanying order: 

ssh-keygen -t rsa -b 4096 -C ""

Duplicate the yield from the feline order and return to the GitLab's web interface. Snap SSH Keys from the left-hand vertical route menu to get to the SSH Keys setup page. 

In the Key textarea glue the public key you recently replicated from your neighborhood machine, set an illustrative title and snap on the Add key catch: 

Presently you should have the option to push and pull your venture changes from your neighborhood PC without giving your GitLab account qualifications. 


This instructional exercise strolled you through the establishment and setup of GitLab on Ubuntu 18.04. You likewise figured out how to alter your profile settings, how to change the username and add a SSH key. You would now be able to make your first undertaking and begin utilizing your GitLab. 

In the event that you have questions, don't hesitate to leave a remark underneath.