December 3, 2021
How to install GitLab On Ubuntu 20.04

How To Install Gitlab Community Edition (CE) On Ubuntu 20.04 LTS

On this article we will learn how to install Gitlab Community Edition (CE) on Ubuntu 20.04 LTS operating system.

Introduction

GitLab is a web-based software development tool which provides a Git repository manager and DevOps lifecycle tool. It provides features rich tool that offers issue tracking, continuous integration (CI/CD), Kubernetes itegration, deployment pipeline etc. GitLab has two distributions: the Enterprise Edition and the Community Edition. GitLab community edition is opensource whereas the enterprise edition comes with premium additional features. On this tutorial we learn how to install GitLab Community Edition (CE) on Ubuntu 20.04.



GitLab CE Installation On Ubuntu 20.04 LTS

Prerequisites

On this tutorial we will install GitLab on Ubuntu by using GitLab package repository instead of manually download and install the .deb package. Before continuing the installation process, there are several prerequisites that must be met as below.

  • An Ubuntu 20.04 LTS Server with sufficient disk space
  • An account with sudo or root access to run privileged commands.
  • Good internet access

Installing GitLab

On this section, we will explain the GitLab installation process on Ubuntu 20.04 LTS. The installation process will be consist of several stages as shown below :

  1. Update System
  2. Install Package Dependencies
  3. Add GitLab Package Repository
  4. Install GitLab Package

1. Update System

At the first stage, we will update our Ubuntu 20.04 LTS system. By updating the system, we will have our server with all the latest stable releases from Ubuntu 20.04 Repository. This task can be done by submitting command line : sudo apt update.

ramans@otodiginet:~$ sudo apt update
[sudo] password for ramans: 
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]    
Hit:2 http://us.archive.ubuntu.com/ubuntu focal InRelease                              
Get:3 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]             
Get:4 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [27.6 kB]
Get:5 http://security.ubuntu.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [60.9 kB]
Get:6 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 DEP-11 Metadata [2,464 B]
Get:7 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Update system

2. Installing GitLab Package Dependencies

Then we will install required package dependencies, by submitting command line : sudo apt-get install -y curl openssh-server ca-certificates.

ramans@otodiginet:~$ sudo apt-get install -y curl openssh-server ca-certificates
Reading package lists... Done
Building dependency tree       
Reading state information... Done
ca-certificates is already the newest version (20210119~20.04.1).
ca-certificates set to manually installed.
The following additional packages will be installed:
  ncurses-term openssh-sftp-server ssh-import-id
Suggested packages:
  molly-guard monkeysphere ssh-askpass
The following NEW packages will be installed:
  curl ncurses-term openssh-server openssh-sftp-server ssh-import-id
0 upgraded, 5 newly installed, 0 to remove and 338 not upgraded.
Need to get 849 kB of archives.
After this operation, 6,420 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 curl amd64 7.68.0-1ubuntu2.6 [161 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu focal/main amd64 ncurses-term all 6.2-0ubuntu2 [249 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 openssh-sftp-server amd64 1:8.2p1-4ubuntu0.2 [51.5 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 openssh-server amd64 1:8.2p1-4ubuntu0.2 [377 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu focal/main amd64 ssh-import-id all 5.10-0ubuntu1 [10.0 kB]
Install GitLab Package Dependencies
Install GitLab Package Dependencies



Then we will install email by sybmitting command line : sudo apt-get install -y postfix.

ramans@otodiginet:~$ sudo apt-get install -y postfix
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  procmail postfix-mysql postfix-pgsql postfix-ldap postfix-pcre postfix-lmdb postfix-sqlite sasl2-bin | dovecot-common
  resolvconf postfix-cdb postfix-doc
The following NEW packages will be installed:
  postfix
0 upgraded, 1 newly installed, 0 to remove and 338 not upgraded.
Need to get 1,198 kB of archives.
After this operation, 4,540 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 postfix amd64 3.4.13-0ubuntu1 [1,198 kB]
Fetched 1,198 kB in 8s (155 kB/s)                                                                           

3. Add GitLab Package Repository

On this stage, we have to add GitLab package repository by submitting command line : curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh|sudo bash.

ramans@otodiginet:~$ curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh|sudo bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5933  100  5933    0     0   4560      0  0:00:01  0:00:01 --:--:--  4560
Detected operating system as Ubuntu/focal.
Checking for curl...
Detected curl...
Checking for gpg...
Detected gpg...
Running apt-get update... done.
Installing apt-transport-https... done.
Installing /etc/apt/sources.list.d/gitlab_gitlab-ce.list...done.
Importing packagecloud gpg key... done.
Running apt-get update... done.

The repository is setup! You can now install packages.
Adding GitLab Repository
Adding GitLab Repository

4. Install GitLab Package

After all prerequisites are met, then we just install GitLab CE package by submitting command line : sudo apt-get install gitlab-ce.

ramans@otodiginet:~$ sudo apt-get install gitlab-ce
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  gitlab-ce
0 upgraded, 1 newly installed, 0 to remove and 338 not upgraded.
Need to get 922 MB of archives.
After this operation, 2,518 MB of additional disk space will be used.
Get:1 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal/main amd64 gitlab-ce amd64 14.1.1-ce.0 [922 MB]
Fetched 922 MB in 8min 27s (1,818 kB/s)                                                                                       
Selecting previously unselected package gitlab-ce.
(Reading database ... 191072 files and directories currently installed.)
Preparing to unpack .../gitlab-ce_14.1.1-ce.0_amd64.deb ...
Unpacking gitlab-ce (14.1.1-ce.0) ...
Setting up gitlab-ce (14.1.1-ce.0) ...
It looks like GitLab has not been configured yet; skipping the upgrade script.

       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.
  


     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/
  

Thank you for installing GitLab!



Install GitLab CE on Ubuntu 20.04 LTS
Install GitLab CE on Ubuntu 20.04 LTS

Configuring GitLab Server

To enable our GitLab server is reachable from external network, we have to allow port 80 and or 443 are reachable. To make enable it, we will open firewall for these port by submitting commande line : sudo ufw allow http, sudo ufw allow https and sudo ufw allow OpenSSH.

ramans@otodiginet:~$ sudo ufw allow http
[sudo] password for ramans: 
Rules updated
Rules updated (v6)
ramans@otodiginet:~$ sudo ufw allow https
Rules updated
Rules updated (v6)
ramans@otodiginet:~$ sudo ufw allow OpenSSH
Rules updated
Rules updated (v6)

if we want to make some changes with our GitLab server, for example we want to host it somewhere, then we can do it by editing the /etc/gitlab/gitlab.rb file , then submit the command line: sudo gitlab-ctl reconfigure to take effect.

ramans@otodiginet:~$ sudo gitlab-ctl reconfigure
Starting Chef Infra Client, version 15.14.0
resolving cookbooks for run list: ["gitlab"]
Synchronizing Cookbooks:
  - gitlab (0.0.1)
  - logrotate (0.1.0)
  - package (0.1.0)
  - redis (0.1.0)
  - postgresql (0.1.0)
  - monitoring (0.1.0)
  - registry (0.1.0)
  - mattermost (0.1.0)
  - gitaly (0.1.0)
  - consul (0.1.0)
  - praefect (0.1.0)
  - gitlab-kas (0.1.0)
  - gitlab-pages (0.1.0)
  - nginx (0.1.0)
  - runit (5.1.3)
  - letsencrypt (0.1.0)
  - acme (4.1.3)
  - crond (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Recipe: gitlab::default

After everything is completed, then we can start the GitLab application with the command line: sudo gitlab-ctl start .

ramans@otodiginet:~$ sudo gitlab-ctl start
ok: run: alertmanager: (pid 22792) 188s
ok: run: gitaly: (pid 22755) 190s
ok: run: gitlab-exporter: (pid 22766) 190s
ok: run: gitlab-workhorse: (pid 22735) 191s
ok: run: grafana: (pid 22883) 187s
ok: run: logrotate: (pid 21770) 400s
ok: run: nginx: (pid 22309) 298s
ok: run: node-exporter: (pid 22746) 190s
ok: run: postgres-exporter: (pid 22876) 187s
ok: run: postgresql: (pid 21983) 382s
ok: run: prometheus: (pid 22774) 190s
ok: run: puma: (pid 22227) 321s
ok: run: redis: (pid 21807) 394s
ok: run: redis-exporter: (pid 22768) 190s
ok: run: sidekiq: (pid 22245) 315s
GitLab Started | sudo gitlab-ctl start
GitLab Started | sudo gitlab-ctl start

And then we can check it with command line : sudo gitlab-ctl status.

ramans@otodiginet:~$ sudo gitlab-ctl status
run: alertmanager: (pid 22792) 240s; run: log: (pid 22553) 302s
run: gitaly: (pid 22755) 242s; run: log: (pid 21855) 439s
run: gitlab-exporter: (pid 22766) 242s; run: log: (pid 22385) 325s
run: gitlab-workhorse: (pid 22735) 243s; run: log: (pid 22287) 353s
run: grafana: (pid 22883) 239s; run: log: (pid 22686) 259s
run: logrotate: (pid 21770) 452s; run: log: (pid 21779) 449s
run: nginx: (pid 22309) 350s; run: log: (pid 22319) 347s
run: node-exporter: (pid 22746) 242s; run: log: (pid 22363) 336s
run: postgres-exporter: (pid 22876) 239s; run: log: (pid 22580) 295s
run: postgresql: (pid 21983) 434s; run: log: (pid 21995) 431s
run: prometheus: (pid 22774) 242s; run: log: (pid 22525) 308s
run: puma: (pid 22227) 373s; run: log: (pid 22238) 370s
run: redis: (pid 21807) 446s; run: log: (pid 21824) 443s
run: redis-exporter: (pid 22768) 242s; run: log: (pid 22404) 318s
run: sidekiq: (pid 22245) 367s; run: log: (pid 22256) 364s
Checking GitLab running | sudo gitlab-ctl status
Checking GitLab running | sudo gitlab-ctl status

Don’t forget to reset the root user password, so that we can use the application at the initial initiation. This task is can be done by submitting command line : sudo gitlab-rake "gitlab:password:reset[root]".

ramans@otodiginet:~/Desktop$ sudo gitlab-rake "gitlab:password:reset[root]"
Enter password: 
Confirm password: 
Password successfully updated for user with username root.
GitLab | Reset root password
GitLab | Reset root password

Testing GitLab Application

After all are set, now we can test the GitLab Server by hitting its URL at http://localhost for navigating GitLab web interface.

GitLab | Login page



GitLab |Create New Project
GitLab |Create New Project

Conclusion

On this article we have shown you how to install GitLab Community Edition application tools on Ubuntu 20.04 LTS server, a web-based software development tool which provides a Git repository manager and DevOps lifecycle tool. I hope this article can be useful for those who need it. Learn more about GitLab on GitLab official website. Stay safe, stay at home.

Share this article via :

Leave a Reply

Your email address will not be published. Required fields are marked *