How to Install GitLab CE on Ubuntu 24.04 (Noble Numbat): A Step-by-Step Guide
GitLab Community Edition (CE) is a powerful, open-source, self-hosted DevOps platform. It empowers development teams to collaborate effectively, manage source code with Git, track issues, automate build, test, and deployment pipelines (CI/CD), and much more. GitLab CE is a popular choice for developers looking for a robust CI/CD solution, and the best part is that you can install and run it for free on your own infrastructure.
This comprehensive guide provides step-by-step instructions to install GitLab CE on a fresh Ubuntu 24.04 LTS (Noble Numbat) server, ensuring a smooth, secure, and functional setup.
Why Choose Self-Hosted GitLab CE on Ubuntu 24.04?
- Complete DevOps Platform: Offers source code management, issue tracking, CI/CD, container registry, security scanning, and more in one integrated platform.
- Full Control: Self-hosting gives you complete control over your data, infrastructure, and configuration.
- Cost-Effective: GitLab CE is free and open-source.
- Ubuntu 24.04 LTS: Leverage the stability and long-term support of the latest Ubuntu LTS release.
- Customization: Tailor the installation to your specific needs.
Prerequisites
- A server running a fresh installation of Ubuntu 24.04 LTS (Noble Numbat).
- A domain name (e.g.,
gitlab.yourdomain.com
) pointed to your server’s public IP address. - Sudo privileges or root access on the server.
- Recommended minimum resources: 4 CPU cores and 4GB RAM for optimal performance, especially with CI/CD usage.
Step 1: Prepare Your Ubuntu 24.04 System
First, ensure your system’s package list and installed packages are up-to-date.
sudo apt update -y
sudo apt upgrade -y # Optional, but recommended
Note: If the upgrade
command installs a new kernel or other critical system components, a reboot might be necessary.
# Reboot if necessary if you upgraded. No need to reboot if you just did update.
sudo reboot
Step 2: Install Essential Dependencies
GitLab requires a few dependencies to function correctly, including ca-certificates
for HTTPS communication, curl
for downloading the installation script, openssh-server
for Git access over SSH, and postfix
(or another Mail Transfer Agent) for sending email notifications (like password resets, pipeline statuses, etc.).
sudo apt install -y curl openssh-server ca-certificates postfix tzdata perl
During the postfix
installation, you will likely be prompted for configuration:
- Choose ‘Internet Site’ when asked for the type of mail configuration.
- Enter your server’s fully qualified domain name (FQDN), such as
gitlab.yourdomain.com
, when asked for the ‘System mail name’. This should match the domain you plan to use for GitLab access.
Step 3: Add the Official GitLab CE Repository
GitLab provides a script to easily add its official package repository to your system. This ensures you get the correct and latest version of GitLab CE.
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
Example Output (will mention noble for Ubuntu 24.04):
Detected operating system as Ubuntu/noble.
Checking for curl...
Detected curl...
Checking for gpg...
Detected gpg...
Running apt-get update... done.
Installing apt-transport-https... done.
Installing /etc/apt/sources.list.d/gitlab_gitlab-ce.list...done.
Importing packagecloud gpg key... done.
Running apt-get update... done.
The repository is setup! You can now install packages.
Step 4: Install the GitLab CE Package
Now that the repository is configured, you can install the main GitLab CE package using apt
.
sudo apt install gitlab-ce -y
This command downloads and installs GitLab and all its components. This step can take several minutes as the package is quite large.
Example Output Snippet (showing installation on noble):
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
# ... (dependency information) ...
The following NEW packages will be installed:
gitlab-ce
# ... (download progress) ...
Get:1 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ noble/main amd64 gitlab-ce amd64 <VERSION> [SIZE]
# ... (unpacking and setup) ...
*. *.
*** ***
***** *****
.****** *******
******** ********
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,,
,*,.
_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __ \
/ /_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_.___/
Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
sudo gitlab-ctl reconfigure
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
# ... (potential survey link) ...
Step 5: Configure GitLab Instance (External URL & Initial Run)
Before GitLab can run correctly, you must configure the URL users will use to access it.
- Edit the Configuration File: Open the main GitLab configuration file using a text editor like
nano
.sudo nano /etc/gitlab/gitlab.rb
- Set the External URL: Find the line starting with
external_url
. Uncomment it if necessary (remove the leading#
) and replace the default value with your HTTP domain name for now (we’ll configure HTTPS later).Change 'http://gitlab.example.com' to your actual domain external_url 'http://gitlab.yourdomain.com'
- Save and Close: Press
Ctrl+X
, thenY
, thenEnter
to save and exitnano
. - Apply Configuration: Run the
gitlab-ctl reconfigure
command. This command applies the changes fromgitlab.rb
, configures all the necessary components (Nginx, Puma, PostgreSQL, Redis, etc.), and starts GitLab for the first time. This process can take several minutes.sudo gitlab-ctl reconfigure
Wait patiently for the command to complete. You’ll see a lot of output as various services are configured.
Step 6: Secure with Firewall (UFW)
It’s crucial to configure a firewall to allow only necessary traffic. Ubuntu uses ufw
(Uncomplicated Firewall). We need to allow SSH (port 22), HTTP (port 80), and HTTPS (port 443).
# Allow OpenSSH
sudo ufw allow OpenSSH
# Allow HTTP and HTTPS
sudo ufw allow http
sudo ufw allow https
# Enable the firewall
sudo ufw enable
# Press 'y' to confirm
# Check the status
sudo ufw status
Example ufw status
Output:
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
80/tcp ALLOW Anywhere
443/tcp ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
80/tcp (v6) ALLOW Anywhere (v6)
443/tcp (v6) ALLOW Anywhere (v6)
Step 7: Initial Login and Security Hardening
- Retrieve Initial Root Password: GitLab automatically generates a secure initial password for the
root
user. You can find it in a temporary file (this file is typically removed after the first 24 hours or the nextreconfigure
).sudo cat /etc/gitlab/initial_root_password
Example Output:# WARNING: This value is valid only... (rest of warning message) ... Password: <YOUR_TEMPORARY_ROOT_PASSWORD> # NOTE: This file will be automatically deleted...
Carefully copy and save this password. You’ll need it to log in for the first time. - Log In: Open your web browser and navigate to the
external_url
you configured (e.g.,http://gitlab.yourdomain.com
). You should see the GitLab login page.- Username:
root
- Password: The temporary password you retrieved in the previous step.
- You will likely be prompted to change the root password immediately upon first login. Choose a strong, unique password.
- Username:
- Disable Public Sign-ups (Recommended for Private Instances): For security, especially on publicly accessible servers, disable user self-registration.
- After logging in as
root
, click the Admin Area icon (wrench) in the top navigation bar. - Go to Settings -> General in the left sidebar.
- Expand the Sign-up restrictions section.
- Uncheck the box labeled Sign-up enabled.
- Scroll down and click Save changes.
- After logging in as
Step 8: Enable HTTPS with Let’s Encrypt SSL
Using HTTPS is essential for security. GitLab has built-in support for obtaining and renewing free SSL certificates from Let’s Encrypt.
- Edit Configuration: Open the GitLab configuration file again. Bash
sudo nano /etc/gitlab/gitlab.rb
- Update External URL to HTTPS: Change the
external_url
to usehttps
instead ofhttp
. Ruby# Change http to https external_url 'https://gitlab.yourdomain.com'
- Enable Let’s Encrypt: Find the Let’s Encrypt section (or add these lines if they don’t exist). Uncomment and configure them:
Enable Let's Encrypt integration letsencrypt['enable'] = true # Optional: Set contact email for Let's Encrypt expiry notices letsencrypt['contact_emails'] = ['[email protected]'] # Use a valid email address # Optional: Configure auto-renewal settings (defaults are usually fine) # letsencrypt['auto_renew'] = true # letsencrypt['auto_renew_hour'] = 0 # letsencrypt['auto_renew_minute'] = 30 # Randomize minute to avoid LE load spikes # letsencrypt['auto_renew_day_of_month'] = "*/4"
- Save and Close: Press
Ctrl+X
, thenY
, thenEnter
. - Reconfigure GitLab: Apply the HTTPS changes. This will trigger the Let’s Encrypt process to obtain a certificate. Ensure your DNS records are correctly pointing your domain to the server’s IP address.
sudo gitlab-ctl reconfigure
This might take a few minutes again. - Verify: Access your GitLab instance using
https
(e.g.,https://gitlab.yourdomain.com
). Your browser should show a valid SSL certificate (lock icon). You can also check the status of GitLab services:sudo gitlab-ctl status
Conclusion
Congratulations! You have successfully installed and configured GitLab Community Edition on your Ubuntu 24.04 LTS server, complete with basic security hardening and HTTPS enabled via Let’s Encrypt. You now have a powerful, self-hosted DevOps platform ready for your projects.
From here, you can start creating users, groups, projects, and explore GitLab’s extensive features, including setting up CI/CD pipelines to automate your software development lifecycle.
Need to install GitLab on Ubuntu 22.04 – check out this procedure
Recent Comments