Installing and maintaining GitLab CE on Ubuntu Server

Aug 09, 2018 - 2 min read

Follow the simple steps below to install GitLab Community Edition on a Ubuntu Server. Instructions were tested with a fresh copy of Ubuntu Server 18.04.1 LTS running on a VirtualBox 5.2.16 VM (Bridged Adapter Network mode).

Install GitLab

  1. Install prerequisites (enables ssh on your server, see [1])

    sudo apt-get install -y curl openssh-server ca-certificates
  2. Update the OS (optional, see [2])

    sudo -- sh -c 'apt-get update; apt-get upgrade -y; apt-get dist-upgrade -y; apt-get autoremove -y; apt-get autoclean -y'
  3. Run omnibus setup

    curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
  4. Set access URL and install (see [3])

    sudo EXTERNAL_URL="http://my-gitlab-url-or-ip/" apt-get install gitlab-ce
  5. Open the HTTP port

    sudo ufw allow http
  6. Open http://my-gitlab-url-or-ip/ in web browser to set a password for the root user

  7. Login as root with the new password

  • HDD: 20GB (depends on the size of your repos)
  • CPU: 2 cores
  • RAM: 8GB

More details: install requirements.

Update GitLab

# update to latest version
sudo apt-get update && sudo apt-get install gitlab-ce

Backup GitLab

# save a backup to /var/opt/gitlab/backups
sudo gitlab-rake gitlab:backup:create STRATEGY=copy

Configure email settings

Configure GitLab to send emails by editing the /etc/gitlab/gitlab.rb and then running the reconfigure command:

sudo nano /etc/gitlab/gitlab.rb

# edit the settings using examples below, save the file

sudo gitlab-ctl reconfigure

More details: smtp settings.

To check if your settings are valid, send a test email using bundled tools:

sudo gitlab-rails console
Notify.test_email('test.address@yourcompany.com', 'Message Subject', 'Message Body').deliver_now

Gmail configuration example

For simple use cases, you will probably have to allow less secure apps to access the account.

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.gmail.com"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "gitlab@yourcompany.com"
gitlab_rails['smtp_password'] = "password"
gitlab_rails['smtp_domain'] = "smtp.gmail.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
gitlab_rails['smtp_openssl_verify_mode'] = 'peer'

gitlab_rails['gitlab_email_from'] = "gitlab@yourcompany.com"
gitlab_rails['gitlab_email_reply_to'] = "gitlab@yourcompany.com"

Zoho configuration example

Create a new account for GitLab, eg. gitlab@yourcompany.com and enable IMAP in the Zoho control panel.

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.zoho.com"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "gitlab@yourcompany.com"
gitlab_rails['smtp_password'] = "password"
gitlab_rails['smtp_domain'] = "smtp.zoho.com"
gitlab_rails['smtp_authentication'] = "plain"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false

gitlab_rails['gitlab_email_from'] = "gitlab@yourcompany.com"
gitlab_rails['gitlab_email_reply_to'] = "gitlab@yourcompany.com"

[1] GitLab omnibus installation instructions
[2] Ubuntu server update and upgrade
[3] GitLab configuration