Install Gitlab on Ubuntu 20.04 LTS Focal Fossa Linux

In this tutorial we will learn the commands and steps to install the alternative self-hosted GitLab from GitHub on Ubuntu 20.04 Focal fossa via the terminal.

What is Gitlab?

GitLab is a version control system (VCS). It is based completely on Git, a distributed versioning system that is made available as open source software. Git is by far the most widely used VCS in the world. GitLab is not that different from GitHub, both web-based solutions rely on Git to manage the various repositories created by developers. Everyone who knows GitHub already knows what Gitlab is, but if not, then it’s an alternative to Github. It is a solution that was written in 2011 by Ukrainian Dmitriy Zaporozhets in collaboration with Valery Sizov using the programming language Ruby on Rails. After Microsoft acquired GitHub in 2018, many users are switching to GitLab to ease a platform’s monopoly.

As a version management platform, the central task of GitLab is to save and document all changes made by developers to files and their source code in such a way that they can be easily traced at any time. Hence, GitLab including Github is rather inclined and used by programmers and developers to make it easy for them. A version control system allows multiple developers to work on the same project at the same time. Learn more about the history of this platform at Wikipedia.

Steps to install Gitlab on Ubuntu 20.04 LTS

By now you would already have an idea of ​​what Gitlab is. Now let’s look at the steps to install it directly on your Ubuntu 20.04 LTS Linux. However, you can follow this guide for other Linux systems such as Linux Mint, Debian, and similar supported operating systems.

1. Perform the apt update

Update the system repository cache so that the system recognizes the latest versions of the packages available for installation. This also updates the system packages.

sudo apt update && sudo apt upgrade

2. Install the dependencies required to set up Gitlab

There are a couple of tools and packages we need before we can proceed, we needed them to properly install GitLab on our system.

sudo apt install curl openssh-server ca-certificates tzdata perl

(Optional) Well, those who also want to use the same system or server that they want to set up this Git platform on and use it to send email notifications to users, install Postfix, an open source mail transfer agent, who forwards and delivers emails.

sudo apt install postfix -y

During the installation of Postfix you will be asked to set it up, select the ‘Internet Site’ option and then add your external DNS for the email name and set up other required things.

However, if you want to use an SMTP server to send email notifications instead of Sendmail or Postfix; First, install the GitLab using the steps given below, and then edit it /etc/gitlab/gitlab.rb Add the SMTP server details there.

After this run gitlab-ctl reconfigure. Learn more about it in official documentation.

3. Run the GitLab installation script

Since GitLab is not available through the default Ubuntu 20.04 base repository, just run the given command on your command terminal, it will download a script to add the GitLab repository, GPG key, and other required packages on your set up system.

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

GitLab installation script on Ubuntu 22.04 20.4

4. Install GitLab on Ubuntu 20.04 LTS

After adding a repository we can simply use the APT package manager to install all the required packages needed to install GitLab on our system; run the specified command.

sudo apt install gitlab-ce

5. Open the ports in the firewall

There are some common ports like HTTP, HTTPS and SSH ports that need to be opened in the system firewall if enabled. Here are the commands:

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

6. Get an automatically generated Gitlab root password

Since we didn’t set a password for the root user, GitLab will create one automatically. To see what that is, use the given command:

sudo cat /etc/gitlab/initial_root_password

Login root password Gitlab on Ubuntu 20.04

7. Access the web interface for setup

Once the installation is complete, go to your browser and point to the server IP address or domain url to access Gitlab’s web interface.

http://server-ip
or
http://your-domain.com

If you are using it on the same PC that the installation is going on, you can use it http://localhost

GitLab registration

If you want to use the fully qualified domain name, first make sure your DNS A record is pointing to the server IP address where you are installing this version control platform, then add the domain url you want to use .

Use your root domain or subdomain such as git.example.com by editing:

sudo nano /etc/gitlab/gitlab.rb

Find line:

external_url 'http://example.com'

Substitute example.com with which domain you want to use. Then save the file by pressing Ctrl + O, hit them Input Key, and then Ctrl + X break up.

Set the domain URL on GITLAB

After you’ve set the domain url, run the GitLab reconfigure command.

sudo gitlab-ctl reconfigure

8. Sign in to see the GitLab dashboard

Now use the user root and the password you received Step 7 of this article to sign up.

Register GiHub alternative under Ubuntu

Once you are signed in, you will be presented with the dashboard for managing planned and other core settings.

Gitlab installation on Ubuntu 20.04 or 22.04

9. Update and update

Since the packages from GitLab were installed with the APT repository, simply running the update and upgrade command will also ensure that this platform is up to date.

sudo apt update && sudo apt upgrade

Remove or uninstall

If you think you no longer need GitLab on your system, you can simply remove it by typing:

sudo apt remove gitlab-ce

Where can repository usage be removed:

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

Conclusion

That way, we can quickly get started with Gitlab on Ubuntu 20.04, while readers can visit the official documentation page for managing GitLab to learn more about how to set it up.

Other articles:

How to install Gnome 41 in Ubuntu 20.04 LTS using PPA
Set the root user password in Ubuntu 20.04 LTS fossa
How to install Octave on Ubuntu 22.04 | April 20

About Willie Ash

Check Also

Thunderbird 102 includes an improved import tool

The team that develops the Thunderbird email client has been working on the next major …