Skip to main content
Self-hosting GitLab gives you full control over your source code and collaboration workflows. Whether you’re managing internal company projects or keeping private code off public platforms, running your own GitLab instance is a practical and cost-effective alternative to paid hosted git services.

Why self-host GitLab?

There are three common reasons to run your own GitLab instance:
  • Internal company projects — keep sensitive code within your own infrastructure without relying on external providers.
  • Private personal projects — some code isn’t suitable for public hosting, and self-hosting gives you full ownership.
  • Cost savings — most hosted git services charge for private repositories or seat-based plans. A single cloud server can often be cheaper than the equivalent hosted tier.

Before you begin

GitLab is a resource-intensive application. Make sure your server meets the following requirements before proceeding.
GitLab requires a minimum of 4 GB RAM to run reliably. Running it on an underpowered server will result in poor performance or instability. For production use, 8 GB RAM or more is strongly recommended.
GitLab uses port 22 for SSH-based git operations (e.g., git clone git@your-server:...). If your server already has SSH running on port 22, you will have a conflict. Either move your system SSH to a different port before installing GitLab, or configure GitLab to use an alternate SSH port and update your git remote URLs accordingly.
GitLab ships with its own bundled nginx web server. If you are already running nginx on the host machine, these two instances will conflict on port 80/443. The recommended approach is to disable your host nginx and let GitLab’s built-in nginx handle all port forwarding. Alternatively, you can configure GitLab to listen on a non-standard port and proxy to it, but this adds complexity.

Installation

1

Install GitLab using the official package

Follow the official GitLab installation guide for your Linux distribution. The recommended approach is to use the GitLab omnibus package, which bundles all dependencies — including PostgreSQL, Redis, and nginx — into a single installer.For Ubuntu/Debian, the install script looks like:
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash
sudo apt-get install gitlab-ee
Avoid deploying GitLab inside Docker. The additional memory overhead from containerization compounds GitLab’s already high baseline memory usage, and the port 22 passthrough adds further networking complexity.
2

Configure the external URL

After installation, open the GitLab configuration file and set the external_url. This is the URL that GitLab will use to generate links in emails, clone URLs, and the web interface.Open /etc/gitlab/gitlab.rb and set the following at a minimum:
# /etc/gitlab/gitlab.rb
external_url 'http://git.yourdomain.com'
Replace git.yourdomain.com with your actual domain or server IP. If you plan to use HTTPS, set the URL with https:// and GitLab’s built-in nginx can manage SSL termination for you using Let’s Encrypt.
3

Apply the configuration

After saving your changes to gitlab.rb, run the reconfigure command to apply them:
sudo gitlab-ctl reconfigure
This command re-generates all GitLab service configurations and restarts the relevant processes. It may take a few minutes to complete.
4

Verify the installation

Once reconfiguration finishes, check that all services are running:
sudo gitlab-ctl status
You should see services like nginx, postgresql, redis, sidekiq, and puma all listed as run. Open your browser and navigate to your external_url — you should be greeted by the GitLab sign-in page.The initial root password is stored at /etc/gitlab/initial_root_password. Use it to log in as root and then immediately change the password under your account settings.
5

Configure DNS and firewall

Point your domain’s DNS A record to the server’s public IP address. Make sure your firewall allows inbound traffic on:
  • Port 80 (HTTP)
  • Port 443 (HTTPS, if configured)
  • Port 22 (SSH for git operations)
# Example using ufw
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 22/tcp

Ongoing maintenance

GitLab releases updates regularly. To upgrade, update the package through your system’s package manager and run gitlab-ctl reconfigure again afterward. Always back up your data before upgrading using:
sudo gitlab-backup create
Backups are stored in /var/opt/gitlab/backups by default.