install gitlab on ubuntu vps

How to Install Gitlab on Ubuntu 20.04 LTS


GitLab is a free and open-source web-based code repository for DevOps. It is a popular alternative to GitHub providing wiki, issue-tracking, and continuous integration and deployment pipeline features, using an open-source license, developed by GitLab Inc.

In this tutorial, you will learn how to install Gitlab on Ubuntu 20.04 LTS Server, along with how to set up GitLab to your liking or for your team’s requirements.


  • Recommended OS: Ubuntu 20.04.
  • 4 cores is the recommended minimum number of cores and supports up to 500 users
  • 4GB RAM is the required minimum memory size and supports up to 500 users
  • User account: A user account with sudo or root access.
  • Other GitLab installation minimum requirements

Step 1. Update Operating System

Update your Ubuntu operating system to make sure all existing packages are up to date:

$ sudo apt update && sudo apt upgrade -y

The tutorial will be using the sudo command and assuming you have sudo status.

Step 2. Install Dependencies for GitLab

Before you install GitLab on ubuntu system, you will need to install the dependencies for it so that you can install and operate GitLab. Open your terminal and execute the following command:

$ sudo apt install curl ca-certificates apt-transport-https gnupg2 -y

Step 3. Create & Import GitLab Repository

By default, GitLab does not come packaged in Ubuntu’s default repositories, and this means you will need to create one manually. However, GitLab has created a handy APT script for you to download and execute to aid you in this task. Download the GitLab APT script using the curl command:

# Install GitLab Community edition
$ curl -s | sudo bash

Example output from the script:Install GitLab Community edition


Now run the apt update command to verify and sync the new repository.

$ sudo apt update

Step 4. Install Gitlab on Ubuntu

The next part of the tutorial is to install GitLab, and you should have already used the apt update command to sync the newly created and modified repository. Now execute the install command using the following:

$ sudo apt install gitlab-ce

Once the installation is complete, you should get the following output in your terminal.

install gitlab-ce screenshot

Step 5. Configure GitLab

With GitLab installed, you can now configure SSL, the domain name or subdomain name passwords, and much more. The tutorial will go over the basic setup options that should be done. However, you can do alternative settings to those listed below. First, open the “gitlab.rb” configuration file using any text editor:

$ sudo nano /etc/gitlab/gitlab.rb

The first setting will be setting the domain, navigating down to line 36, and finding the following. Change this to your subdomain name or domain.

external_url ''

Next, set up TLS/SSL with Let’s Encrypt, which starts at 2297. By default, all settings are commented out with “#.” You will need to uncomment the following lines.

 letsencrypt['enable'] = true
 letsencrypt['contact_emails'] = ['']
 letsencrypt['auto_renew'] = true
 letsencrypt['auto_renew_hour'] = 4
 letsencrypt['auto_renew_day_of_month'] = "*/4"
 letsencrypt['auto_renew_log_directory'] = '/var/log/gitlab/lets-encrypt'

Once done, CTRL+O then exits the file with CTRL+X. Now run the reconfigure command as follows.

$ sudo gitlab-ctl reconfigure

Now, using the following command, you will start the GitLab services on your system:

$ sudo gitlab-ctl start

You can check the status of services either running on your system or not by executing the following command:

$ sudo gitlab-ctl status
[sudo] password for administrator:
run: alertmanager: (pid 501894) 179552s; run: log: (pid 415365) 218416s
run: crond: (pid 863617) 852s; run: log: (pid 863616) 852s
run: gitaly: (pid 418483) 217014s; run: log: (pid 396856) 230629s
run: gitlab-exporter: (pid 501905) 179552s; run: log: (pid 415280) 218435s
run: gitlab-kas: (pid 864146) 679s; run: log: (pid 397134) 230568s
run: gitlab-workhorse: (pid 501915) 179551s; run: log: (pid 412702) 219295s
run: grafana: (pid 501924) 179551s; run: log: (pid 415826) 218193s
run: logrotate: (pid 858595) 3093s; run: log: (pid 396790) 230647s
run: nginx: (pid 865271) 3s; run: log: (pid 412751) 219285s
run: node-exporter: (pid 501957) 179550s; run: log: (pid 415260) 218442s
run: postgres-exporter: (pid 501963) 179549s; run: log: (pid 415390) 218410s
run: postgresql: (pid 418529) 217011s; run: log: (pid 396925) 230596s
run: prometheus: (pid 501974) 179549s; run: log: (pid 415329) 218424s
run: puma: (pid 864140) 681s; run: log: (pid 412630) 219315s
run: redis: (pid 418542) 217010s; run: log: (pid 396826) 230636s
run: redis-exporter: (pid 501989) 179548s; run: log: (pid 415305) 218428s
run: registry: (pid 863655) 842s; run: log: (pid 863654) 842s
run: sidekiq: (pid 863818) 767s; run: log: (pid 412650) 219304s

In the end, you will receive the following message in your terminal. To view the root (GitLab) password, run the following command.

sudo cat /etc/gitlab/initial_root_password

Example output:initial root password screenshot


As above, you can see the password is tmk58exa4VC5P87FwfrhkdpT5grZ7ziewnAquZBr3yg= and that this file will be automatically deleted in 24 hours.

Step 6. Access GitLab

Now that the backend is set, it is time to log in and see your GitLab. First, open up the domain path where GitLab was assigned in the configuration file.


Next, sign in using the username “root” and the password you received, which in the tutorial case was tmk58exa4VC5P87FwfrhkdpT5grZ7ziewnAquZBr3yg=.

Example:gitlab login page


You are successfully logged in as the root account, and you will hit the default landing page.

Example:gitlab landing page

From here, you can proceed to set up and configure GitLab to suit your requirements or your team. One of the first things you should do is go to the admin section and configure the security, such as 2FA, changing root passwords, and much more before adding any team members. This can all be found by clicking on the Menu > Admin in the top left-hand corner of the page. Example:

gitlab admin page

Step 7. Create Cronjob for GitLab Auto Backup

By default, there are no backups created or configured. This should be set using a cronjob, and the frequency set a value that suits your availability of resources and frequency of GitLab changes. First, open your crontab.

$ sudo crontab -e

Next, add the following example and modify the time to suit your needs. If you are unsure of the timing, then visit

00 */1 * * *  gitlab-rake gitlab:backup:create

The above creates a backup every 1 hours exactly.

Once done, CTRL+O then exits the file with CTRL+X. Alternatively, you can run the task manually by executing the following command.

$ sudo gitlab-rake gitlab:backup:create

As above, you will get a message advising the backup is done, along with a message that sensitive files are not included due to security risks.

Comments and Conclusion

Congratulations! You have successfully installed Gitlab. Thanks for using this tutorial on install Gitlab on Ubuntu 20.04 Focal Fossa system. For additional help or useful information, we recommend you to check the official Gitlab website.

The tutorial is tested on VPS Mart, so it works fine on Our Ubuntu VPS Hosting, we recommend  Professional Linux VPS Plan and above.

Table of Contents
    Add a header to begin generating the table of contents
    Scroll to Top