Skip to main content

Command Palette

Search for a command to run...

Day 1&2: Installing and Configuring GitLab on Ubuntu

Updated
3 min read
Day 1&2: Installing and Configuring GitLab on Ubuntu

I am using a DigitalOcean free account, which gives me $200 in credits. You can use my referral code to get the same offer: https://m.do.co/c/1fd4ef5ca074.

To set up the server, I created a Droplet with the following specifications:

  • 8GB RAM, 4-core CPU (recommended for optimal performance)

  • Ubuntu 24.04 LTS (must use one of: 20.04 LTS, 22.04 LTS, or 24.04 LTS)

Additionally, I configured my DNS A record to point my GitLab subdomain (gitlab.hassandevops.site) to my server's public IP address using GoDaddy as my domain registrar. Make sure to do this in your GoDaddy DNS settings before proceeding.

GitLab is a popular DevOps platform that allows you to manage repositories, CI/CD pipelines, and more. In this guide, we will walk through the installation and initial configuration of GitLab on an Ubuntu server.

Step 1: Install and Configure Dependencies

Before installing GitLab, ensure that your system is up-to-date and that necessary dependencies are installed. Run the following commands:

sudo apt-get update
sudo apt-get install -y curl openssh-server ca-certificates tzdata perl

Additionally, install Postfix (or an alternative SMTP solution) to enable notification emails:

sudo apt-get install -y postfix

During the Postfix installation, a configuration screen may appear. Choose 'Internet Site' and press enter. Use your server's external DNS for 'mail name', then press enter. If additional configuration screens appear, accept the defaults by pressing enter.

Step 2: Add the GitLab Package Repository and Install GitLab

To install GitLab, first add the GitLab package repository:

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash

Then, install GitLab with the following command. Be sure to replace https://gitlab.example.com with your desired GitLab URL:

sudo EXTERNAL_URL="https://gitlab.example.com" apt-get install gitlab-ee

If you wish to specify a particular version of GitLab, use:

# List available versions:
apt-cache madison gitlab-ee

# Install a specific version:
sudo EXTERNAL_URL="https://gitlab.example.com" apt-get install gitlab-ee=16.2.3-ee.0

# Pin the installed version to prevent auto-updates:
sudo apt-mark hold gitlab-ee

# Show pinned versions:
sudo apt-mark showhold

i use this for installing GitLab on gitlab.hassandevops.site, use:

sudo EXTERNAL_URL="https://gitlab.hassandevops.site" apt-get install gitlab-ee

# List available versions:
apt-cache madison gitlab-ee

# Install a specific version:
sudo EXTERNAL_URL="https://gitlab.hassandevops.site" apt-get install gitlab-ee=16.2.3-ee.0

# Pin the installed version:
sudo apt-mark hold gitlab-ee

# Show pinned versions:
sudo apt-mark showhold

Step 3: Access GitLab and Log In

Once installation is complete, navigate to your GitLab URL in a browser.

If you did not specify a custom administrator password, a randomly generated password will be stored in:

/etc/gitlab/initial_root_password

Use this password along with the username root to log in.


With GitLab installed, you can now configure your repositories, CI/CD pipelines, and user management. For further customization and security enhancements, check out the official GitLab documentation.

GitLab Access URL:

https://gitlab.hassandevops.site

More from this blog

DevOps Journey with M Hassan

174 posts

I am writing these blogs because I recently completed a comprehensive DevOps course where I gained in-depth knowledge of the topics mentioned. As I progressed through the course, I realized the importance of having a concise and accessible resource to revise and reinforce my understanding of each topic. Therefore, I decided to create cheat sheets in the form of blog posts. These cheat sheets will not only serve as a handy reference for myself but also benefit others who are also interested in mastering DevOps concepts. By documenting each topic and providing concise explanations, I aim to create a valuable resource that simplifies complex concepts and facilitates hands-on practice. This way, I can solidify my own understanding while helping others on their DevOps journey.

Day 1&2: Installing and Configuring GitLab on Ubuntu