Before you start
A team wants to keep its code, merge requests and issue tracking on its own server. GitLab brings these together. In CI/CD, a code change can start an automated pipeline of jobs such as tests and application builds, with deployment added when configured. A runner executes each job. Operating GitLab also makes you responsible for the code, review history and CI data. This single-node installation uses the Linux package to manage compatible components together. We place the runner on a separate build host so its processing does not compete with repositories and backups.
You need sudo, internet access and a domain pointing to the server. Plan for 8 vCPU, 16 GB RAM and SSD storage; 80 GB is a starting budget that must grow with your repositories. Replace gitlab.example.com with your domain in every command.
For a fresh installation, inspect the candidate from the official repository before installing it. Pin the approved version when repeating the installation across environments. For an existing GitLab instance, follow its upgrade path and required intermediate releases.
Choose hosting responsibility and edition
| Choice | License/capabilities | Maintenance | Operational trade-off |
|---|---|---|---|
| GitLab CE, self-managed | Community code under MIT; core Free features | Your OS, package upgrades, TLS, storage, backups | Small/private teams needing the core workflow; paid EE features absent |
| GitLab EE, self-managed | EE license; Free tier without paid license; Premium/Ultimate need subscription | Same self-hosting duties; license/tier controls added features | Select for enterprise capabilities/support after checking the actual tier |
| GitLab.com SaaS | Hosted Free/Premium/Ultimate offerings; quotas and capabilities vary by plan | Vendor runs the platform; you manage access, projects, retention and Runners | Less platform work; evaluate residency, limits and export/recovery needs |
What the package manages
HTTPS requests reach NGINX/Workhorse and then Rails. Behind that path, Gitaly manages Git repositories, PostgreSQL stores application state, and Redis/Sidekiq handle queues and background work. Use gitlab-ctl to control those services; do not add a competing web server or database without a defined requirement.
Prepare Ubuntu
sudo apt update
sudo apt upgrade -y
sudo apt install -y curl ca-certificates openssh-server tzdata perl ufw
sudo systemctl enable --now sshReboot and reconnect if Ubuntu requests it. Allow SSH before enabling UFW. If SSH uses a custom port, replace 22 below. Ports 80 and 443 must be free of other web servers.
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw statusAllow these ports in your provider firewall too. Automatic HTTPS needs public DNS pointing here and inbound port 80. Any published IPv6 record must work as well.
cat /etc/os-release
getent ahosts gitlab.example.com
sudo ss -ltnp
free -h
df -h /var/optPurpose: establish package prerequisites and certificate reachability before installing GitLab. Expected result: Ubuntu 24.04, working DNS, sufficient disk and free TCP 80/443. Verification: test 80 from outside after installation, and verify any AAAA record. Failure analysis: a stale IPv6 record or upstream firewall can break certificate issuance despite correct local UFW. Rollback: retain SSH rules; reverse only new web-port permissions if installation is abandoned. OS upgrades need a pre-change host snapshot, not package removal.
Install GitLab
First download the repository setup script from the official source and inspect it with less before execution. Press q to exit the viewer. Execute the script only after the download succeeds and you have reviewed the file.
curl --fail --show-error --location https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh -o /tmp/gitlab-repository.sh
less /tmp/gitlab-repository.sh
sudo bash /tmp/gitlab-repository.sh
sudo apt update
apt-cache policy gitlab-ceCandidate shows the version apt will install; its source should be packages.gitlab.com. If Candidate is (none), fix the repository first. Then install with your own domain:
sudo EXTERNAL_URL="https://gitlab.example.com" apt install -y gitlab-ce
sudo gitlab-ctl status
dpkg-query -W gitlab-ceInstallation takes a few minutes and requests a Let’s Encrypt certificate. Wait for it to finish. This guide uses CE; choosing EE requires both the EE repository and gitlab-ee package.
The apt candidate is the version choice for a fresh install, not an upgrade plan for an existing instance. Record apt-cache policy and dpkg-query output in the change record. For repeatable provisioning pin an approved package version from apt-cache madison; verify it still supports Ubuntu 24.04 and follow GitLab required upgrade stops when moving from an existing release.
Purpose: Install one coherent GitLab CE package from the vendor repository.
Expected result: gitlab-ctl lists running services and the HTTPS URL answers after startup.
Verification: Run gitlab:check SANITIZE=true and clone a private repository using a regular account.
Failure analysis: Inspect package source, certificate logs, RAM and disk before retrying reconfigure.
Rollback: If a fresh installation fails, preserve the configuration in /etc/gitlab and the data in /var/opt/gitlab, then restore the pre-installation host snapshot. Do not purge data to diagnose the failure.
Sign in and create a project
sudo cat /etc/gitlab/initial_root_passwordOpen your GitLab URL and sign in as root with the Password value. Keep it private: this file is temporary. Change the root password and email, create a regular daily account and restrict public sign-ups for a private team server.
Choose New project, create a private blank project and initialize it with a README. Copy its clone URL. Add your public SSH key to your profile before using Git over SSH. CI/CD jobs need a separate Runner setup later.
Enable 2FA for administrators, restrict sign-ups and external visibility, and use a regular account for daily work. Configure SMTP or another approved mail path before depending on password recovery. Verify SSH host fingerprints out of band, upload only your public key, and test ssh -T git@gitlab.example.com from a workstation. A successful SSH identity test is separate from project authorization.
Purpose: Replace the bootstrap root credential with controlled administration.
Expected result: A secured admin and a regular account can access the private test project.
Verification: Test HTTPS login and authorized SSH clone from a workstation.
Failure analysis: Check mail recovery and user/project permissions separately from SSH identity.
Rollback: Revoke the test key/project and change exposed bootstrap credentials immediately.
Attach a separate Runner with the current token workflow
A runner is the agent that executes CI jobs. Create a project runner in Settings → CI/CD → Runners and obtain its authentication token. Install the official runner and a supported container runtime on a separate build host. Interactive registration keeps the token out of the article and shell history; use the glrt- workflow rather than the old shared registration token.
sudo gitlab-runner register
# URL: https://gitlab.example.com
# Token: enter the project runner authentication token privately
# Executor: docker
# Default image: choose your approved, pinned build image
sudo gitlab-runner verify
sudo systemctl status gitlab-runner --no-pagerExpected result: the Runner is online and a small job completes for its assigned project. Verification: inspect the job log and Runner assignment. Failure analysis: verify Runner-to-GitLab DNS/TLS and container-runtime access; verify does not prove jobs can execute. Keep privileged mode off and never expose the GitLab host socket or secrets to untrusted jobs. Rollback: pause/delete the Runner in GitLab, unregister its local entry and revoke its token.
Runner package installation on the separate build host
If the page does not open
sudo gitlab-ctl status
sudo gitlab-ctl tail nginx
sudo gitlab-rake gitlab:check SANITIZE=trueIf the page is unavailable, check DNS, firewall rules and available memory. A brief 502 during initial startup can mean the application is not ready; persistent errors need log inspection. Exit live logs with Ctrl+C. Configuration lives in /etc/gitlab/gitlab.rb and is applied with the command below. Internal networks without public DNS need their own trusted certificate setup.
sudo gitlab-ctl reconfigurecurl --fail --silent --show-error https://gitlab.example.com/-/health
curl --silent --show-error https://gitlab.example.com/-/readiness
sudo gitlab-ctl status
sudo gitlab-rake gitlab:check SANITIZE=trueHealth tests the web process; readiness tests dependencies and may require configured monitoring allowlists. Restrict these endpoints to your monitoring addresses. Correlate repeated 502s with Puma startup, Gitaly/database errors, memory pressure and free inodes; do not repeatedly restart every service. Monitor backup age, Sidekiq backlog, storage growth, certificate expiry and Runner queue time.
Take an initial backup
sudo gitlab-backup create
sudo gitlab-ctl backup-etcApplication backups normally go to /var/opt/gitlab/backups; configuration and secrets go to /etc/gitlab/config_backup. Copy both securely off the server. External object storage and registry data may need separate backups. Test restoration with the same GitLab version and edition. For future upgrades, back up first and follow the official upgrade path including required intermediate versions.
Rehearse recovery on a separate host with the backup's exact version and edition: restore replaces destination data. Securely restore gitlab.rb, gitlab-secrets.json and certificates, because missing secrets can leave encrypted data unusable. Isolate email, webhooks and runners, stop Puma/Sidekiq, restore using the real backup ID, then reconfigure, restart and check the data.
# Recovery host only, after matching version/edition and restoring secrets
sudo gitlab-ctl stop puma
sudo gitlab-ctl stop sidekiq
# Substitute the actual ID prefix from the backup archive filename
sudo gitlab-backup restore BACKUP=YOUR_BACKUP_ID
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
sudo gitlab-rake gitlab:check SANITIZE=trueBefore upgrading, verify required stops and background migrations, preserve a complete matching backup and test restore. Downgrading the package after database migrations is not a rollback; restore the matching software and backup. Choose recovery objectives for repository writes and CI artifacts separately.
Purpose: Capture data and secrets needed by the same GitLab build.
Expected result: Application/config archives exist privately and copies reach independent storage.
Verification: Inspect backup exit status, retention and a matching-version isolated restore.
Failure analysis: Check disk, object-storage exclusions and lost encryption secrets.
Rollback: If restore fails, keep the live host intact; rebuild the disposable recovery target.
Questions from deployment reviews
Does EE require a paid license to start?
EE can run with Free-tier capabilities without a paid subscription. Premium/Ultimate features require the appropriate subscription; CE and EE packages are distinct.
Is gitlab-backup create enough for disaster recovery?
No. Preserve configuration/secrets, certificates and external storage, and prove restoration on matching software. A completed archive alone is not a recovery test.