Installing GitLab CE
Purpose
Running GitLab on your local network ensures that none of your code resides on external servers, giving you complete control and privacy. You can also run CI/CD pipelines directly on your systems, streamlining development and deployment within your secure environment.
This guide explains how to install GitLab CE on a local Ubuntu 22.04 server. This can be performed on bare metal or inside a virtual machine.
Requirements
This guide assumes you have set up a local authoritative dns resolver and have a KVM/QEMU Hypervisor on Ubuntu to run the GitLab virtual machine on.
The GitLab Requirements Documentation outlines the system requirements for a local GitLab instance.
For a small deployment, a virtual machine with these specs should be fine:
- 2 CPUs
- 8GB RAM
- 64GB storage
Installing GitLab CE
Operating System
Create a new Ubuntu 22.04 LTS server virtual machine. Give it an FQDN. Most people use 'git' as the hostname.
Assign a static IP address to the system, and give it a name in DNS if you've configured a local authoritative resolver. If not, you can add an entry to the /etc/hosts
file of any machine you want to talk to your hosted repositories.
Apply all updates to your system by running the following:
GitLab CE
Installing GitLab CE is straightforward. Run all of these commands as the root user unless otherwise specified.
First, install the required dependencies:
Next, download the repository installation script for GitLab CE on Ubuntu and run it:
Now that GitLab CE's repository definitions and GPG keys are present install GitLab CE using apt:
Firewall Rules
If you use the UFW firewall, adjust your ruleset to allow traffic for GitLab:
After adjusting your firewall rules, ensure the changes have been applied by running ufw status
:
Output
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
80/tcp ALLOW Anywhere
443/tcp ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
80/tcp (v6) ALLOW Anywhere (v6)
443/tcp (v6) ALLOW Anywhere (v6)
Configuring GitLab
Before running GitLab for the first time, edit the configuration file:
Search for external_url
and set the parameter's value to the FQDN of your GitLab server.
Reconfigure GitLab by running:
GitLab Web UI
Once the configuration is completed, you can reach your GitLab deployment with a web browser at the FQDN you configured.
The root user's password was automatically generated during the installation and saved in /etc/gitlab/initial_root_password
. Use these credentials to log into the web UI.
You are now ready to add projects and start storing your source code in your local GitLab server.