Cybersecurity Updates & Tools

Install and Configure GitLab on Ubuntu 18.04 with Omnibus

GitLab is a web-based, open-source Git repository manager written in Ruby. It includes built-in tools for issue tracking, wiki pages, code review, CI/CD pipelines, and project monitoring. GitLab is the most popular self-hosted alternative to GitHub and can import existing projects from GitHub directly, which makes migration straightforward.

This guide shows you how to install GitLab on Ubuntu 18.04 using Omnibus packages, the simplest and most reliable self-hosting method.

Server requirements:

  • At least 4 GB of RAM
  • 2 CPU cores
  • At least 2 GB of swap space
  • A domain name (optional, but needed for HTTPS)

Prerequisite: You need sudo access and UFW firewall is recommended.

Install GitLab on Ubuntu: Dependencies, Postfix, and Repository Setup

Update the package index and install the required dependencies:

bashsudo apt updatesudo apt install curl openssh-server ca-certificates

Install Postfix so GitLab can send notification emails. Run the pre-seed commands to configure it non-interactively:

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

If you prefer to use an external mail service like SendGrid or Mailgun, skip the Postfix install and configure GitLab’s SMTP settings after installation instead.

Add the GitLab CE repository to your system:

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

Install the GitLab package:

bashsudo apt install gitlab-ce

The installation takes a few minutes. A successful install ends with:

Thank you for installing GitLab!

Configure the GitLab URL, Firewall, and SSL Certificate

Open the firewall. Allow SSH, HTTP, and HTTPS traffic through UFW:

bashsudo ufw allow OpenSSHsudo ufw allow httpsudo ufw allow https

Set the GitLab URL. Open the main configuration file:

bashsudo nano /etc/gitlab/gitlab.rb

Find the external_url line near the top and update it to your domain or server IP:

rubyexternal_url 'https://gitlab.example.com'

Use https:// if you have a domain name. Use http:// if you are accessing GitLab via an IP address.

Enable Let’s Encrypt if you are using a domain. Search for the Let’s Encrypt section in gitlab.rb, uncomment these lines, and add your email:

rubyletsencrypt['enable'] = trueletsencrypt['contact_emails'] = ['admin@example.com']

Do not enable Let’s Encrypt if external_url is set to an IP address.

Save the file and run the reconfigure command. This applies your settings and automatically provisions the SSL certificate:

bashsudo gitlab-ctl reconfigure

Complete the Initial Setup via the GitLab Web Interface

Open your domain or IP in a browser. The first screen asks you to set a password for the root administrative account. Enter a strong password and click Change your password.

You will be redirected to the login page. Sign in with username root and the password you just set.

Edit your profile. Click your avatar in the upper-right corner and select Settings. Update your name and email address, then click Update profile settings. GitLab sends a confirmation email to verify the address you entered.

Change the username. Click Account in the left navigation menu. The default admin username is root. Type a new username and click Update username. You will use this new username on your next login and it will appear across all your projects.

Add an SSH key. This lets you push and pull code without entering your password each time. If you do not have an SSH key pair yet, generate one:

bashssh-keygen -t rsa -b 4096 -C "your_email@domain.com"

Display your public key and copy the output:

bashcat ~/.ssh/id_rsa.pub

In the GitLab interface, click SSH Keys from the left navigation menu, paste the key, give it a descriptive title, and click Add key.

GitLab is now installed and running on your Ubuntu 18.04 server. Create your first project from the dashboard and start using it for version control, code review, and CI/CD pipelines. Leave a comment below if you run into any issues.