Install Gitlab on Ubuntu 20.04 LTS Focal fossa Linux

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

What is Gitlab?

GitLab is a version control system( VCS). It is based entirely 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 much different from GitHub, both web-based solutions are based on Git for managing the various repository created by developers. Anyone who is acquainted with GitHub would already know what is Gitlab, still, if you are not then it is an alternative to Github. It is a solution that was written by Ukrainian Dmitriy Zaporozhets in collaboration with Valery Sizov in 2011 using the programming language Ruby on Rails. After Microsoft took over GitHub in 2018, many users switch to GitLab to mitigate the monopoly of one platform.

Being a version management platform the key task of GitLab is to save and document all changes to files done by developers and their source code to make them easily traceable at any time. Hence, GitLab including Github is more inclined and used by the programmers and developers to make things easy for them. Due to a version control system, several developers can work on the same project simultaneously. Know more about this platform’s history at Wikipedia.

 

Steps to install Gitlab on Ubuntu 20.04 LTS

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

1. Perform Apt Update

Refresh the system repository cache, so that the system could know what are the latest versions of the packages available to install, this will also update the system packages.

sudo apt update && sudo apt upgrade

 

2. Install Dependencies required to set Gitlab

There are a few tools and packages we need before moving forward, we required them for the proper installation of 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 where they are setting up this Git platform and use it to send email notifications to users, then install Postfix, an open-source mail transfer agent that routes and delivers e-mail.

sudo apt install postfix -y

While Installing Postfix, it will ask you to set it up, go for the ‘Internet Site’ option, and then add your external DNS for mail name and set other required things.

Whereas, 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 after that edit /etc/gitlab/gitlab.rb There add the SMPT server details.

After that run gitlab-ctl reconfigure. Know more about it at the official documentation.

Install Dependencies required to set Gitlab

 

3. Run GitLab installation Script

As the GitLab is not available through the default base repository of Ubuntu 20.04, hence, on your command terminal simply run the given command, it will download a script to add the GitLab repository, GPG key, and setting up of other required packages on your 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 for the install of all the required packages required to install GitLab on our system; run the given command.

sudo apt install gitlab-ce

 

5. Open Ports in the firewall

There are a few common ports such as HTTP, HTTPS, and SSH ports that have 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 Auto-generated Gitlab root password

As we have not set any password for the root user, GitLab will create one automatically. To see what is that use the given command:

sudo cat /etc/gitlab/initial_root_password

Login root password Gitlab on Ubuntu 20.04

 

7.  Acess web interface to setup

Once the installation is completed, go to your browser and point to the server IP address or domain URL to access the web interface of Gitlab.

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

If you are using it on the same PC where the installation is done, then you can the use http://localhost

GitLab Login

If you want to use the fully qualified domain name, then first makes sure your DNS A record point to the server IP address where you are installing this version control platform, and then add the domain URL that 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'

Replace example.com with whatever domain you want to use. After that save the file by pressing Ctrl+O, hit the Enter key, and then Ctrl+X to exit.

Set domain URL on GITLAB

Once you have set the Domain URL, run the GitLab reconfigure command.

sudo gitlab-ctl reconfigure

 

8. log in to see the GitLab Dashboard

Now, use the user- root and the password you get in Step 7 of this article to log in.

Login GiHub alternative on Ubuntu

Once you logged in, the Dashboard to manage projected and other core settings will appear for you.

Gitlab installation on Ubuntu 20.04 or 22.04

9. Update and upgrade

As the packages of GitLab have been installed using the APT repository, hence simply running of update and upgrade command will also make sure this platform is up to date.

sudo apt update && sudo apt upgrade

 

Remove or Uninstallation

When you think that you don’t require GitLab anymore on your system, you can easily remove it by typing:

sudo apt remove gitlab-ce

Where to remove repository use:

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

 

Conclusion

In this way we can quickly start with Gitlab on Ubuntu 20.04 whereas to know more about its setup, readers can visit the official documentation page for Administrating GitLab.

 

Other Articles:

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

 

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.