Introduction
GitLab is an open-source application mainly used to host Git repositories, with additional development capabilities such as tracking issues, code review, CI/CD, and more. It is a complete DevOps platform that enables professionals to perform all the tasks in a project from project planning and source code management to monitoring and security.
In this article, you will understand how to install Gitlab CE on Ubuntu OS 20.04.
Prerequisites
- A root or non-root user with
sudo
privileges. - Hardware Requirement: 4GB RAM of memory, 4 cores for your CPU. For more information regarding the hardware. Refer to the following GitLab documentation page.
- Note: Installation steps remain same for other versions of Ubuntu OS 18.04 and 22.04.
1. Upgrade the system package and GitLab dependencies
a. Upgrade the package index:
sudo apt upgrade -y
b. Updating the GitLab dependencies:
sudo apt install ca-certificates curl openssh-server postfix tzdata perl
2. Installation of GitLab CE
a. Navigate into the/tmp
directory
cd /tmp
b. Download the GitLab CE to your UbuntuOS by running the command:
curl -LO https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh
c. Review the bash script to see what actions it performs. For more information about the script, Refer to GitLab installation instructions:
less /tmp/script.deb.sh
d. Run the bash script installer:
sudo bash /tmp/script.deb.sh
e. Once the repository has been added, install GitLab CE using theapt
package manager command:
sudo apt install gitlab-ce
Output
3. Enabling the firewall
a. You must ensure that your firewall rules allow web traffic before configuring GitLab. We need to enable the firewall with ufw
:
sudo ufw enable
b. Port mapping protocols for HTTP and HTTPS are available in the /etc/services file, so you can allow this traffic by name. If you haven't enabled OpenSSH traffic yet, you'll need to allow that traffic
sudo ufw allow http
sudo ufw allow https
sudo ufw allow OpenSSH
c. You can view the current status of your firewall by running the following command:
sudo ufw status
Output
4. Editing the GitLab Configuration File
Update configuration files and run reconfiguration commands before using the application. First, open the GitLab configuration file by using the nano command:
sudo nano /etc/gitlab/gitlab.rb
a. Setting the hostname and other parameters: Replace gitlab.example.com with a valid domain for the GitLab server.
- Change HTTP to HTTPS and update your domain by replacing it with gitlab.example.com in
external_url
configuration line
external_url 'https://your_domain/'
b. Find theletsencrypt['contact_emails']
settings. Update with the proper email addresses and uncomment the line.
letsencrypt['contact_emails'] = ['johnsmith@gmail.com']
c. Run the following command to reconfigure GitLab:
sudo gitlab-ctl reconfigure
The process will configure a Let's Encrypt certificate on your domain.
5. Access GitLab CE Web Interface
Once the setup of GitLab CE on Ubuntu OS 22.04|20.04|18.04 is done, open the URL http://your_domain
on your browser to complete the setup of Gitlab.
a. Enter the following details on the GitLab login page:
- Username: root
- Password: It is stored in the below-mentioned path of the system:
sudo nano /etc/gitlab/initial_root_password
Copy the password and enter it in the password field of the GitLab login page. You will log in to the application and be redirected to the landing page.
GitLab setup is completed and you can perform all the operations in GitLab.