Install GitLab CE on Ubuntu VPS Free
GitLab Community Edition is a self-hosted Git platform with everything built-in: repositories, merge requests, CI/CD pipelines, issue tracking, and container registry. Installing it on your own VPS means your code stays within your organization and saves subscription costs as your team grows.
Install GitLab CE via Package
sudo apt update
sudo apt install -y curl ca-certificates tzdata perl
# Add GitLab repository
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
# Install with external URL configured
sudo EXTERNAL_URL="https://gitlab.yourdomain.com" apt install gitlab-ce
Configure GitLab (/etc/gitlab/gitlab.rb)
sudo nano /etc/gitlab/gitlab.rb
# Main URL
external_url 'https://gitlab.yourdomain.com'
# Automatic SSL from Let's Encrypt
letsencrypt['enable'] = true
letsencrypt['contact_emails'] = ['[email protected]']
# Email (using SMTP)
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.yourdomain.com"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = "yourpassword"
gitlab_rails['smtp_tls'] = false
gitlab_rails['smtp_starttls_auto'] = true
gitlab_rails['gitlab_email_from'] = '[email protected]'
# Disable signup (if desired)
gitlab_rails['gitlab_signup_enabled'] = false
# Apply configuration
sudo gitlab-ctl reconfigure
Get Root Password and Access Admin
# Root password is stored here (valid for 24 hours)
sudo cat /etc/gitlab/initial_root_password
# Access https://gitlab.yourdomain.com
# Username: root
# Password: (from file above)
# Change password immediately after first login
Set Up GitLab Runner (CI/CD)
# Install Runner
curl -sL https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
sudo apt install gitlab-runner -y
# Register runner
sudo gitlab-runner register
# Enter GitLab URL: https://gitlab.yourdomain.com
# Enter token from Settings > CI/CD > Runners
# Select executor: shell or docker
Set Up Automatic Backup
# Backup immediately
sudo gitlab-backup create
# Set up daily cron backup
sudo crontab -e
# Add line:
0 2 * * * /opt/gitlab/bin/gitlab-backup create CRON=1 2>/dev/null
# Backups are stored in /var/opt/gitlab/backups/
ls /var/opt/gitlab/backups/
/etc/gitlab/gitlab-secrets.json. Back up this file separately from the main backup. Without it, restore will fail even if you have backups.
For a VPS running GitLab, you need good specifications. VPS providers like asiagb.com offer packages specifically for development teams with high load support and SSD NVMe storage that keeps GitLab responsive even with multiple CI/CD pipelines running.
Verify GitLab is Working Correctly
# Check all service status
sudo gitlab-ctl status
# Test web server
curl -I https://gitlab.yourdomain.com
# View logs in real-time
sudo gitlab-ctl tail
# Check health endpoint
curl https://gitlab.yourdomain.com/-/health
sudo gitlab-rake gitlab:check performs a comprehensive health check of all GitLab components and suggests fixes if problems are found. Run this after installation and after every upgrade.
Common Issues & Troubleshooting
Error: "502 Bad Gateway" After Installation
GitLab is still loading services. Wait 2-3 minutes after reconfigure, then try again. If it persists, check RAM:
free -h
sudo gitlab-ctl status
sudo gitlab-ctl tail puma
SSL Certificate Failed to Issue (Let's Encrypt)
Port 80 must be open and DNS must point to the VPS before reconfigure:
sudo ufw allow 80
sudo ufw allow 443
# Check DNS
dig +short gitlab.yourdomain.com
sudo gitlab-ctl reconfigure
GitLab Very Slow After Startup
This is common with low RAM. Reduce worker count in gitlab.rb:
# /etc/gitlab/gitlab.rb
puma['worker_processes'] = 2
sidekiq['concurrency'] = 5
sudo gitlab-ctl reconfigure
Git Push/Pull Slow (SSH)
Check authorized_keys file permissions and sshd configuration:
sudo gitlab-rake gitlab:shell:check
ls -la /var/opt/gitlab/.ssh/authorized_keys
Frequently Asked Questions
How is GitLab CE different from GitHub?
GitHub is a public cloud service; GitLab CE is software you install on your own server. The advantage is data stays under your control, unlimited private repositories, and CI/CD minutes are not metered separately. The downside is you manage the server yourself.
Does GitLab CE support Container Registry?
Yes. GitLab CE includes Container Registry. Enable it in gitlab.rb with registry_external_url. Teams can push Docker images to the GitLab registry and pull them in CI/CD pipelines.
How do I upgrade GitLab CE?
Upgrade via apt, but always backup first. Upgrade one major version at a time, don't skip versions:
sudo apt update
sudo apt install gitlab-ce
sudo gitlab-ctl reconfigure