Knowledge Base Hub

Browse through our helpful how-to guides to get the fastest solutions to your technical issues.

Home  >  VPS FAQ  >  How to Install GitLab on Ubuntu?
Top Scroll

How to Install GitLab on Ubuntu?

 4 min

GitLab is a DevOps platform providing a collection of tools for managing Git repositories, collaboration, issue tracking, CI/CD, and software deployment. You are able to set up GitLab on your own Ubuntu VPS and work with projects on a private server rather than offloading everything onto a hosted GitLab instance.

Self-hosting GitLab allows you to have more control over your server environment, repository data, access permissions, and configuration.

In this tutorial you will learn how to install GitLab on an Ubuntu VPS, configure the domain, enable HTTPS, secure the installation, and access the GitLab dashboard.

Why Run GitLab on a VPS?

It is ideal for development teams, agencies, companies, and single developers who want more control over their development environment and are hosting GitLab on a VPS server.

Typical benefits include:

Consolidate group project files and repositories. One stop for your code.

  • Dev env (private): Manage your repos on your infrastructure.
  • CI/CD: Test and deploy your stuff automatically.
  • Teamwork: Problems, merge requests, project discussion
  • Access control: Add users and grant the correct permissions.
  • Self-Managed Infrastructure: Use GitLab on your infrastructure for your project needs.

Requirements

Before you install GitLab, check the basic requirements of your Ubuntu VPS.

You will need:

  • An Ubuntu VPS.
  • Root or sudo access.
  • SSH access to the VPS.
  • A domain name pointed to your VPS.
  • A stable internet connection.
  • Adequate CPU, RAM, and storage for your GitLab workload.

GitLab needs significant system resources, especially when hosting multiple repositories or supporting several users. For smaller deployments, GitLab’s current application guidance recommends at least 2 CPU cores and 4 GB RAM, while larger teams need substantially extra resources.

Steps to Install GitLab on Ubuntu

Step 1: Update the Ubuntu Packages

Connect to the VPS using SSH and update the package repository:

sudo apt update

You upgrade the installed packages:

sudo apt upgrade -y

Keeping Ubuntu updated helps prevent package conflicts during the GitLab installation.

Step 2: Install GitLab Dependencies

GitLab requires several supporting packages to work correctly.

Install the required dependencies using:

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

During the Postfix installation, Ubuntu asks you to select the mail configuration type.

Select:

Internet Site

Then enter your server’s hostname or domain name when prompted.

Postfix delivers e-mails, including notifications and other system messages, during the GitLab installation process.

Step 3: Adding GitLab Repository

GitLab has an official package repo for easier installation and future package management.

Perform:

sudo bash -c 'curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash'

These commands will add the GitLab Enterprise Edition repository to your Ubuntu system.

Note: If you want to install GitLab Community Edition instead, replace gitlab-ee with gitlab-ce in the package commands where applicable.

Step 4. Install GitLab

With the repository added, install GitLab:

sudo apt install -y gitlab-ee

The installation will take a few minutes depending on your VPS resources and network speed.

When you install GitLab, the system automatically installs the necessary services and configuration files.

Step 5. Setting up the GitLab domain

A domain name is an easier way to access your GitLab installation than a server IP address.

Edit the GitLab config file:

sudo vi /etc/gitlab/gitlab.rb

Find the external_url setting and change it to the domain.

For example:

external_url https://gitlab.example.com

Replace gitlab.example.com with your domain name or subdomain that you pointed to the VPS.

Step 6: Enable HTTPS

Using HTTPS protects communication between your browser and GitLab.

If the domain is correctly pointed to the VPS, you configure GitLab’s built-in Let’s Encrypt integration.

In /etc/gitlab/gitlab.rb, ensure that your URL uses HTTPS:

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

You configure the email address used for certificate-related notifications.

After saving the configuration file, apply the changes.

sudo gitlab-ctl reconfigure

GitLab will reconfigure its services using the settings in gitlab.rb.

Step 7: Configure the Firewall

If UFW is enabled on your Ubuntu VPS, allow the services needed to access GitLab.

Run:

sudo ufw allow http

sudo ufw allow https

sudo ufw allow OpenSSH

Check the firewall status:

sudo ufw status

You must see rules for HTTP, HTTPS, and SSH.

Step 8: Find the Initial GitLab Password

When you install GitLab, it creates the first root account and generates a temporary password.

You can see it with:

sudo nano /etc/gitlab/initial_root_password

Search For:

Password:

Copy the generated password and keep it safe.

Step 9: Login to the GitLab Dashboards

Open your web browser and navigate to your configured GitLab domain:

https://gitlab.example.com

You may need to visit the GitLab login page.

Usage:

Username: root

Password: Your first GitLab password

Click into account settings after logging in and change the root password.

Step 10: Create SSH key for GitLab

SSH keys let you connect to GitLab repositories without having to provide your username and password every time.

Generate an SSH key on your local computer:

ssh-keygen

Select the default file location or a custom location.

To display your public key run:

cat ~ /.ssh/id_rsa.pub

Copy the entire output.

Step 11: Check the GitLab Installation

Verify the GitLab solutions using:

sudo gitlab-ctl status

The command shows the status of the GitLab components.

You can also check the global configuration for GitLab:

# sudo gitlab-ctl reconfigure

If you haven’t made any configuration errors, GitLab should be ready to use.

To test SSH connectivity, run:

ssh -T git@gitlab. example

Replace the domain with your GitLab domain.

Conclusion

With GitLab installed on an Ubuntu VPS, you now have a self-hosted environment to manage source code, projects, collaboration, and development workflows.

The basic installation process is updating Ubuntu, adding the official repository, installing GitLab, setting up the domain and HTTPS, setting up the firewall, and setting up account security.

You can host GitLab on your own VPS and create repositories, add team members, manage issues, review code, build automated CI/CD workflows, and a lot more. If you are going to use it in a production environment, you should also consider regular backups, adequate server resources, security updates, and controlled user access.

For our Knowledge Base visitors only
Get 10% OFF on Hosting
Special Offer!
30
MINS
59
SECS
Claim the discount before it’s too late. Use the coupon code:
STORYSAVER
Note: Copy the coupon code and apply it on checkout.