How to Install GitLab on Ubuntu ⋆ ALexHost SRL

Test your skills on our all Hosting services and get 15% off!

Use code at checkout:

Skills
31.10.2024

How to Install GitLab on Ubuntu

GitLab is a powerful open-source DevOps platform that provides version control, continuous integration/continuous delivery (CI/CD), and collaboration tools. Installing GitLab on Ubuntu allows you to manage projects and collaborate with teams efficiently. This guide will walk you through installing GitLab on an Ubuntu server.

1. Update System Packages

Before starting the installation, ensure your system packages are up-to-date:

sudo apt update && sudo apt upgrade -y

2. Install Required Dependencies

GitLab requires some additional packages to function properly. Install these by running:

sudo apt install -y curl openssh-server ca-certificates tzdata perl

3. Add the GitLab Repository

GitLab offers an official repository that simplifies the installation process. To add it, first download the GitLab script:

curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash

This script sets up the repository and allows you to install GitLab directly from the official package source.

4. Install GitLab

Now, install GitLab Community Edition (CE). Replace https://gitlab.example.com with the desired URL for accessing your GitLab instance.

sudo EXTERNAL_URL=”https://gitlab.example.com” apt install gitlab-ce

This command installs GitLab and configures it to use the specified external URL. If you’re using a local server, you can substitute your server’s IP address instead.

5. Configure GitLab

After installation, configure GitLab using the following command:

sudo gitlab-ctl reconfigure

This command configures GitLab with the default settings and generates all necessary components, such as databases and services.

6. Access GitLab in a Web Browser

Once GitLab is installed and configured, you can access it through the URL you specified (https://gitlab.example.com or your server’s IP address).

When you first access GitLab, you’ll be prompted to set up an admin password. After setting the password, you can log in with:

  • Username: root
  • Password: (the password you just set)

7. Setting Up GitLab Email Notifications (Optional)

If you want GitLab to send email notifications, configure the email settings in the GitLab configuration file located at /etc/gitlab/gitlab.rb.

Example email configuration:

gitlab_rails[‘smtp_enable’] = true gitlab_rails[‘smtp_address’] = “smtp.yourmailprovider.com” gitlab_rails[‘smtp_port’] = 587 gitlab_rails[‘smtp_user_name’] = “your_email@example.com” gitlab_rails[‘smtp_password’] = “your_email_password” gitlab_rails[‘smtp_domain’] = “example.com” gitlab_rails[‘smtp_authentication’] = “login” gitlab_rails[‘smtp_enable_starttls_auto’] = true

After modifying the configuration file, reconfigure GitLab to apply changes:

sudo gitlab-ctl reconfigure

8. Managing GitLab Services

GitLab provides several commands to manage its services:

  • Start GitLab:
    sudo gitlab-ctl start
  • Stop GitLab:
    sudo gitlab-ctl stop
  • Restart GitLab:
    sudo gitlab-ctl restart
  • Check GitLab Status:
    sudo gitlab-ctl status

9. Enabling HTTPS (Optional)

For secure access, it’s recommended to enable HTTPS. You can use Let’s Encrypt, a free SSL certificate provider, by modifying /etc/gitlab/gitlab.rb.

Add the following configuration:

letsencrypt[‘enable’] = true letsencrypt[‘contact_emails’] = [‘you@example.com’] letsencrypt[‘auto_renew’] = true

Run the reconfiguration command after saving changes:

sudo gitlab-ctl reconfigure

This configuration enables HTTPS with automatic renewal for your SSL certificate.

10. Basic GitLab Setup

After installation, configure GitLab for your organization by setting up groups, projects, and CI/CD pipelines as needed. GitLab offers an intuitive web interface to manage users, create repositories, and set permissions.

Conclusion

Installing GitLab on Ubuntu is straightforward and provides a powerful platform for DevOps, version control, and project management. With GitLab up and running, you can start collaborating on projects, using GitLab’s robust features for code management and CI/CD.

Test your skills on our all Hosting services and get 15% off!

Use code at checkout:

Skills