Welcome to our guide on how to install GitLab CE on Ubuntu 18.04 / Debian 9. GitLab is a fully-featured platform for accelerated software development. It provides up to scratch features like integrated CI/CD, Kubernetes integration, Auto DevOps, GitLab Container Registry e.t.c.

In our previous guide, we covered how Install Gitlab CE on CentOS 7 / Fedora 29 / Fedora 28. Follow below steps to Install Gitlab CE on Ubuntu 18.04 / Debian 9.

Step 1: Update system & install dependencies

Kickoff the installation by ensuring your system is updated

sudo apt update
sudo apt upgrade -y

Install GitLab dependencies below:

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

Step 2: Configure Postfix Send-Only SMTP Server

GitLab should be able to send emails to you on Git activities. Configure Postfix SMTP Server using the guide below:

Install and configure Postfix as a Send-Only SMTP Server on Ubuntu 18.04/Debian LTS

Step 3: Add the GitLab CE Repository

Once you have all pre-requisites installed, proceed to add GitLab repository to your Ubuntu 18.04 / Debian 9 by running the command:

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

Debian 9 output:

Detected operating system as debian/stretch.
Checking for curl...
Detected curl...
Checking for gpg...
Detected gpg...
Running apt-get update... done.
Installing debian-archive-keyring which is needed for installing 
apt-transport-https on many Debian systems.
Installing apt-transport-https... done.
Installing /etc/apt/sources.list.d/gitlab_gitlab-ce.list...done.
Importing packagecloud gpg key... done.
Running apt-get update... done.

The repository is setup! You can now install packages.

Ubuntu 18,04 output:

Detected operating system as Ubuntu/bionic.
Checking for curl...
Detected curl...
Checking for gpg...
Detected gpg...
Running apt-get update... done.
Installing apt-transport-https... done.
Installing /etc/apt/sources.list.d/gitlab_gitlab-ce.list...done.
Importing packagecloud gpg key... done.
Running apt-get update... done.

The repository is setup! You can now install packages.

Step 3: Install GitLab CE on Ubuntu 18.04 / Debian 9

Once the repository has been added, install GitLab CE on Ubuntu 18.04 / Debian 9 using the apt package manager command:

sudo apt update
sudo EXTERNAL_URL="http://gitlab.example.com" apt -y install gitlab-ce

Replace gitlab.example.com with your actual domain name before executing the command. When done, start your GitLab instance by running the following command:

sudo gitlab-ctl reconfigure

All GitLab services should be started after configuration.

$ sudo gitlab-ctl status
run: alertmanager: (pid 9775) 5787s; run: log: (pid 12211) 96423s
run: gitaly: (pid 9785) 5787s; run: log: (pid 12018) 96427s
run: gitlab-monitor: (pid 9797) 5786s; run: log: (pid 12048) 96426s
run: gitlab-workhorse: (pid 9810) 5786s; run: log: (pid 11992) 96428s
run: logrotate: (pid 18721) 2185s; run: log: (pid 11994) 96428s
run: nginx: (pid 12043) 5463s; run: log: (pid 11993) 96428s
run: node-exporter: (pid 9836) 5784s; run: log: (pid 12042) 96427s
run: postgres-exporter: (pid 9841) 5784s; run: log: (pid 12213) 96423s
run: postgresql: (pid 9847) 5784s; run: log: (pid 11977) 96428s
run: prometheus: (pid 9855) 5783s; run: log: (pid 12206) 96424s
run: redis: (pid 9868) 5783s; run: log: (pid 11976) 96428s
run: redis-exporter: (pid 9870) 5783s; run: log: (pid 12106) 96426s
run: sidekiq: (pid 15215) 4153s; run: log: (pid 11979) 96428s
run: unicorn: (pid 15343) 4127s; run: log: (pid 11978) 96428s

Step 4: Access GitLab CE Web Interface

Once the installation of GitLab CE on Ubuntu 18.04 / Debian 9 is done, open the URL http://gitlab.example.com on your browser to finish the installation of Gitlab.

On the first screen, you’ll be asked to change the root user password.

Provide the new password and verify then click “Change your password” button.

Login with root as username and password provided.

GitLab Dashboard should look like below.

Step 5: Secure Gitlab CE with SSL Certificate

Read our next article below on how to configure your GitLab server to be accessible via HTTPS

How To Secure GitLab Server with SSL Certificate

GitLab Administrations cheats

Whenever you edit GitLab configuration file – /etc/gitlab/gitlab.rb,reconfigure GitLab service by running:

sudo gitlab-ctl reconfigure
sudo gitlab-rake gitlab:check

To check the status of all GitLab service, use:

sudo gitlab-ctl status

To stop all GitLab services, use:

sudo gitlab-ctl stop

To restart all GitLab services, use:

sudo gitlab-ctl restart

You can restart a specific service by proving service name at the end

$ sudo gitlab-ctl restart logrotate
ok: run: logrotate: (pid 22824) 0s

If you need LDAP Authentication on your GitLab Server, read:

How to Configure GitLab FreeIPA Authentication

Enjoy running GitLab on Ubuntu 18.04/Debian 9 server and stay connected for more informative and hands-on Linux guides.