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 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
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: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.
Configure the external URL
After installation, open the GitLab configuration file and set the Replace
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: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.Apply the configuration
After saving your changes to This command re-generates all GitLab service configurations and restarts the relevant processes. It may take a few minutes to complete.
gitlab.rb, run the reconfigure command to apply them:Verify the installation
Once reconfiguration finishes, check that all services are running: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.Ongoing maintenance
GitLab releases updates regularly. To upgrade, update the package through your system’s package manager and rungitlab-ctl reconfigure again afterward. Always back up your data before upgrading using:
/var/opt/gitlab/backups by default.