Install GitLab CE
GitLab is a comprehensive DevOps platform that provides source code management, CI/CD pipelines, and collaborative tools for software development.
GitLab CE is its the open-source and free version, and ideal for individuals and small teams due to its cost-effectiveness, transparency, and robust feature set.
This post is a step-by-step install guide for GitLab CE on Ubuntu 24.04.
1. Update System Packages
First, update your package lists and upgrade any existing packages to their latest versions. Open your terminal and run:
$ sudo apt update
$ sudo apt upgrade -y
2. Install Dependencies
GitLab requires some dependencies to function correctly. Install them using:
$ sudo apt install -y curl openssh-server ca-certificates postfix
During the Postfix installation, a configuration window will appear.
Choose Internet Site and enter your server’s hostname as the mail server name. This will allow GitLab to send email notifications.
3. Add GitLab APT Repository
Add the GitLab repository by running the following curl command. It will automatically detect your Ubuntu version and set the repository accordingly:
$ curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
4. Install GitLab on Ubuntu 22.04
Run the command below to install and configure GitLab CE on your Ubuntu system. Replace the server’s hostname with your setup:
$ sudo EXTERNAL_URL="http://gitlab.ronbulaon.com" apt install gitlab-ce
After the installation is complete, GitLab will be installed successfully.
The username for the GitLab web interface is root
and the password is stored at /etc/gitlab/initial_root_password
.
Note: If the OS firewall is enabled on your Ubuntu system, allow ports 80 and 443:
$ sudo ufw allow http
$ sudo ufw allow https
5. Access GitLab Web Interface
With GitLab installed and configured, open your web browser and enter your server’s IP address or hostname:
http://<Server-IP-Address-or-Hostname>
Log in with the username root
and the password from /etc/gitlab/initial_root_password
.
$ cat /etc/gitlab/initial_root_password
6. Secure GitLab Web Interface (Optional)
For added security, configure HTTPS for your GitLab instance using a self-signed certificate. Since we’re using a private domain, we’ll use a self-signed certificate to secure GitLab.
Create the following folder and generate self-signed certificates using OpenSSL:
$ sudo mkdir -p /etc/gitlab/ssl
$ sudo chmod 755 /etc/gitlab/ssl
Generate the private key:
$ sudo openssl genrsa -des3 -out /etc/gitlab/ssl/gitlab.ronbulaon.com.key 2048
Create the CSR:
$ sudo openssl req -new -key /etc/gitlab/ssl/gitlab.ronbulaon.com.key -out /etc/gitlab/ssl/gitlab.ronbulaon.com.csr
Remove the passphrase from the key:
$ sudo cp -v /etc/gitlab/ssl/gitlab.ronbulaon.com.{key,original}
$ sudo openssl rsa -in /etc/gitlab/ssl/gitlab.ronbulaon.com.original -out /etc/gitlab/ssl/gitlab.ronbulaon.com.key
$ sudo rm -v /etc/gitlab/ssl/gitlab.ronbulaon.com.original
Create the certificate file:
$ sudo openssl x509 -req -days 1460 -in /etc/gitlab/ssl/gitlab.ronbulaon.com.csr -signkey /etc/gitlab/ssl/gitlab.ronbulaon.com.key -out /etc/gitlab/ssl/gitlab.ronbulaon.com.crt
Remove the CSR file:
$ sudo rm -v /etc/gitlab/ssl/gitlab.ronbulaon.com.csr
Set the permissions on the key and certificate file:
$ sudo chmod 600 /etc/gitlab/ssl/gitlab.ronbulaon.com.key
$ sudo chmod 600 /etc/gitlab/ssl/gitlab.ronbulaon.com.crt
Edit the GitLab configuration file to use HTTPS:
$ sudo vi /etc/gitlab/gitlab.rb
Add the following line:
external_url 'https://gitlab.ronbulaon.com'
Save and exit the file, then reconfigure GitLab:
$ sudo gitlab-ctl reconfigure
Your GitLab interface should now be accessible over HTTPS. Access it using your server’s hostname:
https://gitlab.ronbulaon.com/
When accessing it for the first time, you might see a warning about the connection not being secure. Click Accept the Risk and Continue.
Conclusion
You’ve have now successfully installed GitLab on your Ubuntu 22.04 system.