# 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](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:

```plaintext
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:

```plaintext
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:

```plaintext
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:

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

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

```plaintext
# 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:

```plaintext
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:

```plaintext
/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](https://docs.gitlab.com/ee/install/).

### GitLab Access URL:

[https://gitlab.hassandevops.site](https://gitlab.hassandevops.site)
