There is a new version of this tutorial available for Ubuntu 20.04 (Focal Fossa).

How to Install and Configure GitLab on Ubuntu 18.04 LTS

GitLab is an open source GIT repository manager based on Rails and developed by GitLab Inc. It is a web-based GIT repository manager that allows your team to work on code, perform feature requests, track bugs, and test and implement applications. GitLab provides features such as a wiki, issue tracking, code reviews, activity feeds, and merge management. It is able to host multiple projects.

GitLab is available in four editions:

  1. Gitlab CE (Community Edition) - self-hosted, free and support from the Community forum.
  2. Gitlab EE (Enterprise Edition) - self-hosted, paid app, comes with additional features.
  3. - SaaS, free.
  4. - Private GitLab instance managed by GitLab Inc.

In this tutorial, I will show you step-by-step how to install GitLab CE (Community Edition) on your own Ubuntu 18.04 LTS (Bionic Beaver) server. I will be using the 'omnibus' package provided by GitLab for easy installation.


  • Ubuntu 18.04 Server
  • Min RAM memory 4GB - for better performance, use 8GB
  • Root privileges

What we will do

  1. Update Repository and Upgrade Packages
  2. Install Dependencies
  3. Install GitLab Community Edition
  4. Generate SSL Letsencrypt and DHPARAM Certificate
  5. Configure HTTPS for GitLab
  6. Configure Ubuntu UFW Firewall
  7. GitLab Post-Installation
  8. Testing

Step 1 - Update Repository and Upgrade Packages

Before installing any packages on the system, update all available repositories and then upgrade all packages on the system.

Run apt commands below.

sudo apt update
sudo apt upgrade -y

Wait for the installation packages that will be upgraded.

Install Ubuntu updates

Step 2 - Install Gitlab Dependencies

GitLab needs some packages dependencies for the installation, including curl, postfix, and ca-certificates.

Install GitLab packages dependencies using the apt command below.

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

During postfix installation, you will be prompted about the configuration, select 'Internet Site'.

Configure Postfix

And then enter the server domain name that shall be used for sending an email.

Enter the domain name

And we're ready to install GitLab on the server.

Step 3 - Install GitLab

In this step, we will install GitLab using the omnibus packages. The Omnibus will install all packages, services, and tools required for running GitLab on the server.

Add GitLab repository with the curl command.

curl -sS | sudo bash

Download gitlab install script

And then install GitLab CE Community Edition with the apt command.

sudo apt install gitlab-ce -y

The command will download and install the GitLab CE package, and when the installation is complete, you will see the results as below.

Gitlab CE installation routine starts

Next, we should configure the URL that will be used to access our GitLab server. We will be using a domain named '' for the GitLab access URL and will enable the HTTPS on it.

To change the GitLab URL access, edit the '/etc/gitlab/gitlab.rb' file.

sudo vim /etc/gitlab/gitlab.rb

Now change the 'external_url' value with your own domain name.

external_url ''

Save and exit.

Step 4 - Generate Let's encrypt SSL Certificate and DHPARAM Certificate

In this step, we will generate a new Letsencrypt certificate and DHPARAM certificate for the GitLab domain name ''.

Install the lets encrypt tool using the apt command below.

sudo apt install letsencrypt -y

And after the installation is complete, run the letsencrypt command below.

sudo letsencrypt certonly --standalone --agree-tos --no-eff-email --agree-tos --email [email protected] -d

And when it's complete, you will get the result as shown below.

Get lets encrypt SSL certificate

SSL Letsencrypt certificates have been generated, located in the '/etc/letsencyrpt/' directory.

Next, we will generate the DHPARAM certificate using the OpenSSL command.

Create a new directory '/etc/gitlab/ssl' and run the OpenSSL command below.

sudo mkdir -p /etc/gitlab/ssl/
sudo openssl dhparam -out /etc/gitlab/ssl/dhparams.pem 2048

Now change the permission of the SSL directory.

chmod 600 /etc/gitlab/ssl/*

Get DHPARAM file

And all certificates needed for GitLab HTTPS configuration have been generated.

Step 5 - Configure HTTPS for GitLab

In order to enable the HTTPS for GitLab installation, we need to edit the 'gitlab.rb' file.

Edit the '/etc/gitlab/gitlab.rb' file using the vim command below.

sudo vim /etc/gitlab/gitlab.rb

Change the 'external_url' of Gitlab to the ''.

external_url ''

Now paste configuration below to the '#GitLab Nginx' section.

nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/letsencrypt/live/"
nginx['ssl_certificate_key'] = "/etc/letsencrypt/live/"
nginx['ssl_dhparam'] = "/etc/gitlab/ssl/dhparams.pem"

Save and exit.

Configure SSL in Gitlab

Now run the 'gitlab-ctl' command below.

sudo gitlab-ctl reconfigure

This command will install and configure GitLab based on the '/etc/gitlab/gitlab.rb' configuration file.

And when it's complete, you will see the result as below.

Restart services

The GitLab installation is complete, and HTTPS for GitLab has been enabled.

Step 6 - Configure Ubuntu UFW Firewall

In this step, we will enable the Ubuntu UFW firewall. It's already installed on the system, we just need to start the service. We will run GitLab behind the Ubuntu UFW firewall, so we must open the HTTP and HTTPS ports.

Add ssh, http, and https services to the configuration.

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

And enable the Ubuntu UFW firewall with the command below.

sudo ufw enable

Type 'y' for yes to enabled it.

Now check all services and ports list on the list.

sudo ufw status

And you will get ssh, http, and https services on the list.

Configure the firewall

Step 7 - GitLab Post-Installation

Open the web browser and type in the gitlab URL '', and you will be redirected to the HTTPS connection.

Create a New GitLab Root Password

Type your new password for root GitLab user, and click the 'Change your password' button.

Set Gitlab root password

Now Login as a 'root' user with your own password and click the 'Login' button.

Log in as root

Now you will get the GitLab Dashboard.

Gitlab dashboard

Change Profile

Click the profile button and choose 'Settings'.

Change user profile settings

On the 'Main Settings' section, type the profile name 'hakase' and then click the 'update profile settings' option.

Change Username

Click the 'Account' tab and type the username 'hakase'.

Change username

Now press the 'Update username' button.

Add SSH Key

Generate a new key using the ssh-keygen command as below.

cat ~/.ssh/

Copy the '' key.

Add an SSH key

Now back to the GitLab user dashboard and click the 'SSH Key' menu on the left.

Add SSH key in Gitlab

Paste the ssh public key '' and click the 'Add key' button.

Sign up Restrictions

Click the 'Admin area' button on the middle, then click 'Settings'.

Configure sign-up restrictions

Uncheck the 'signup enabled' option and click the 'Save changes' button.

Account Limit

Click on the 'Account and limit' section and set the default project limit to 20.

Set account limits

And click the 'Save changes' button.

Step 8 - Testing Gitlab

Finally, we will do some tests to ensure that our GitLab system is working properly.

Create New Project

Click the plus icon on the top mid to create a new project repository. Type in your project name, description, and set up the visibility settings of your project. Then click on the 'Create project' button.

Create project

The new project has been created.

Test First Commit and Push

Now we will start adding new content to the repository. Make sure Git is installed on your computer, and we need to set up the global username and email for git with the command below.

git config --global "hakase"
git config --global "[email protected]"

Clone the Repository and add a file.

git clone
cd project01/

You will be asked for the 'hakase' user password. Please type the same password that you used when we accessed GitLab the first time.

Commit a new file to the 'project01' repository.

git add .
git commit -m 'Add file by hakase-labs'

Next, push the change to the repository on the GitLab server.

git push origin master

Type in your password and press Enter to continue. You will see the result as below.

Git test commit

Now open the 'project01' project from your web browser, and you will see that the new file has been added to the repository.

Test project in Gitlab

GitLab installation guide on Ubuntu 18.04 has been completed successfully.


Share this page:

6 Comment(s)