Hostname | IP Address | RAM (GB) | Cores | Storage (GB) | OS |
---|---|---|---|---|---|
gitlab2.dev.naijalabs.net | 192.168.1.232 | 4 | 2 | 150 | Ubuntu 22.04 LTS Jammy Jellyfish |
Learn how to install GitLab CE on Ubuntu 22.04 with this step-by-step guide. Includes CLI examples, troubleshooting tips, and best practices for a smooth deployment.
GitLab CE (Community Edition) is a robust, self-hosted Git repository management system that provides CI/CD, issue tracking, and more. In this guide, we will walk through the step-by-step process of installing GitLab CE on Ubuntu 22.04. This tutorial is designed to be SEO-optimized, providing clear instructions, tables, and CLI examples to help users successfully deploy GitLab CE.
Before proceeding with the installation, ensure you have the following:
Requirement | Details |
---|---|
OS | Ubuntu 22.04 LTS |
User Privileges | Root or sudo privileges |
RAM | Minimum 4GB (8GB recommended) |
Storage | At least 20GB of available disk space |
CPU Cores | 2 or more |
Internet Access | Required to download dependencies |
For this demonstration, we’ve configured our Linux server as follows:
Hostname | IP Address | RAM (GB) | Cores | Storage (GB) | OS |
---|---|---|---|---|---|
gitlab2.dev.naijalabs.net | 192.168.1.232 | 4 | 2 | 150 | Ubuntu 22.04 LTS Jammy Jellyfish |
Step 1: Update and Upgrade System Packages |
Before installing GitLab, update the package index and upgrade existing packages (then, reboot your machine):
sudo apt update && sudo apt upgrade -y && sudo systemctl reboot
Step 2: Install Required Dependencies |
GitLab requires some dependencies for proper installation. Install them using the command below:
sudo apt install -y curl openssh-server ca-certificates tzdata perl
For email notifications, install Postfix:
sudo apt install -y postfix
During installation, select “Internet Site” and configure the system mail name accordingly.
Photo by admingeek from Infotechys
Step 3: Add GitLab Repository and Install GitLab CE |
To install GitLab CE, follow these steps:
Add the GitLab Package Repository |
curl -fsSL https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
Detected operating system as Ubuntu/jammy.
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.
Install GitLab CE |
Replace gitlab2.dev.naijalabs.net
with your actual domain or IP address:
sudo EXTERNAL_URL="http://gitlab2.dev.naijalabs.net" apt install gitlab-ce -y
Photo by admingeek from Infotechys
Step 4: Configure GitLab |
Once installed, configure GitLab using the following command:
sudo gitlab-ctl reconfigure
This step may take several minutes as it configures all necessary services.
Photo by admingeek from Infotechys
Step 5: Adjust Firewall Rules |
Allow HTTP and HTTPS traffic:
sudo ufw allow http
sudo ufw allow https
sudo ufw allow OpenSSH
sudo ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup
Step 6: Access GitLab Web Interface |
Now, open a web browser and navigate to [ http://yourdomain.com
]:
Photo by admingeek from Infotechys
You will be prompted to set a new root password. Once done, log in using:
Username | Password |
root | sudo cat /etc/gitlab/initial_root_password |
You initial root password is stored in /etc/gitlab/initial_root_password
.
sudo cat /etc/gitlab/initial_root_password
# WARNING: This value is valid only in the following conditions
# 1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
# 2. Password hasn't been changed manually, either via UI or via command line.
#
# If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
Password: yI3fpcKMS4j62v+6YiYc8NdZbL87MISajFkqn8m9VwE=
# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
Note: The root password is temporary and will expire in 24 hours. After your initial login, immediately update your password by navigating to your user settings at [http://yourdomain.com/-/user_settings/password/edit]
Photo by admingeek from Infotechys
Step 7: Enable HTTPS (Optional but Recommended) |
For security, configure SSL with Let’s Encrypt:
sudo EXTERNAL_URL="https://yourdomain.com" gitlab-ctl reconfigure
Ensure your domain has a valid DNS record pointing to your server.
Step 8: Start and Enable GitLab Services |
Ensure GitLab services are running:
sudo gitlab-ctl status
If necessary, restart services:
sudo gitlab-ctl restart
Step 9: Configure GitLab for First Use |
Navigate to Admin Area > Settings to:
|
|
|
Issue | Solution |
502 Gateway Error | Restart GitLab with sudo gitlab-ctl restart |
Email Not Sending | Check sudo gitlab-ctl tail postfix logs |
Web UI Not Loading | Ensure firewall allows HTTP/HTTPS traffic |
Congratulations! You have successfully installed and configured GitLab CE on Ubuntu 22.04. You are now ready to create projects, manage repositories, and set up CI/CD pipelines to streamline your development workflow.
Did you find this guide helpful? Your feedback is invaluable to us! Feel free to share this post with those who may benefit!
In this article, we’ll examine Jenkins Vs Github Actions. Learn which CI/CD tool is best for your project’s needs, from setup and integration to scalability
Learn how to install GitLab CE on RHEL 9 or CentOS 9 using Ansible roles. This comprehensive guide covers prerequisites, creating Ansible roles, executing playbooks, and
Learn how to effortlessly install GitLab CE on your RHEL 9 or CentOS 9 system with our comprehensive guide. Follow our step-by-step instructions for a