How to Install GitLab on Ubuntu 18.04/16.04 LTS

In this article, We are going to perform How to Install GitLab on Ubuntu 18.04/16.04 LTS


GitLab is an open source, cloud-based Git repository and version control system.


  • Processor- minimum i3
  • Storage –    480 GB SSD
  • Ram-         8 GB(upto 200 Users)
  • OS-           Ubuntu 18.04/16.04 LTS

update the System Packages

$ sudo apt-get update
$ sudo apt-get upgrade

Install Dependencies Packages

Install below dependencies packages

$ sudo apt-get install -y curl openssh-server ca-certificates

Install Postfix to send email notifications

If you want to use another solution to send emails please skip this step and configure an external SMTP server after GitLab has been installed.

$ sudo apt-get install -y postfix

During Postfix installation a configuration screen may appear.

Select ‘Internet Site’ and press Enter.

Use your server’s external DNS for ‘mail name’ and press Enter.

If additional screens appear, continue to press Enter to accept the defaults.

Install GitLab on Ubuntu

Add the GitLab package repository. Here we are installing omnibus packages and Free Enterprise Edition

$ curl | sudo bash

After installing gitlab packages, Change to the URL at which you want to access your GitLab instance. Installation will automatically configure and start GitLab at that URL.

Generate Let’s Encrypt SSL

Create the /etc/gitlab/ssl directory and generate your key and certificate there:

$ sudo mkdir -p /etc/gitlab/ssl

Change the folder permission.

$ sudo chmod 700 /etc/gitlab/ssl

Go Inside SSL directory and run below command

$ openssl genrsa -out gitlab. 2048

$ openssl req -new -key gitlab. -out gitlab.

Download SSL and copy inside /etc/gitlab/ssl directory

Redirect HTTP requests to HTTPS in Nginx

By default, when you specify an external_url starting with ‘https’, NGINX will no longer listen for unencrypted HTTP traffic on port 80. If you want to redirect all HTTP traffic to HTTPS you can use the redirect_http_to_https setting.

Edit /etc/gitlab/gitlab.rb and add below line after external_url ” ” line

nginx['redirect_http_to_https'] = true

Enable firewall Rule

Enable the SSH, http and https service into Ubuntu UFW Firewall,

$ sudo ufw allow ssh
$ sudo ufw allow http
$ sudo ufw allow https

Check the Firewall Status

$ sudo ufw status

If you using cloud instance the allow above services in inbound rules.

Access GitLab Web Interface

On your first visit, you’ll be redirected to a password reset screen. Provide the password for the initial administrator account and you will be redirected back to the login screen.

Use the default account’s username root to login


Successfully we have performed Install GitLab on Ubuntu 18.04/16.04 LTS

GitLab Project Data Migration from Old Server to New Server

  • Create Same project under same Group
  • Add existing project member on new server and give respective project access.
  • You should be member of old project and new project
  • Clone old Gitlab Project on your local system with below mirroring clone method
  • git clone –mirror OLD-URL
  • Once clone will be done go inside the respective project directory and run below command for data push on new server.
  • git push –mirror NEW-REMOTE


In this article, We have covered install GitLab on Ubuntu, generated SSL certificates, redirected http to https in nginx,enabled firewall rules in Ubuntu .

Related Articles

Git Tutorial

Mahesh Karale

I am Mahesh Karale working as DevOps Engineer. Likes to Explore and Research on Linux, Cloud and DevOps Tools.

Leave a Comment

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

Share via
Copy link