Back

Installing GitLab Community Edition on Your Personal Server

Introduction:

GitLab is a platform that’s specially made for handling repositories and start your smooth software development. By installing GitLab Community Edition on your server you gain control over your codebase and can Easily collaborate with your team. In this blog post we will guide you through the step, by step installation process starting from the requirements and concluding with the configuration of GitLab, on your server..

Prerequisites:

Before you begin the installing GitLab Community Edition process, ensure that you have the following prerequisites:

A Dedicated Server or Virtual Machine:

  • Ensure you have a server or a virtual machine with a supported operating system (Ubuntu, CentOS, Debian, or similar).
  • The server should have enough resources (RAM, CPU, storage) to handle GitLab’s requirements, especially if you expect heavy usage.

Domain Name (Optional):

  • It is recommended to have a domain name pointing to your server’s IP address. This will make accessing GitLab more convenient and secure.

System Updates:

  • Run system updates to ensure your server is up to date with the latest packages and security patches.

Step-by-Step Installation Guide:

Step 1: Install Dependencies

On Ubuntu/Debian:

sudo apt update
sudo apt install -y curl openssh-server ca-certificates

On CentOS/RHEL:

sudo yum update
sudo yum install -y curl policycoreutils openssh-server openssh-clients
sudo systemctl enable sshd
sudo systemctl start sshd
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld

Step 2: Install and Configure Postfix (Optional)

If you want to use GitLab’s email notifications and services, install and configure Postfix:

On Ubuntu/Debian:

sudo apt install -y postfix

On CentOS/RHEL:

sudo yum install -y postfix
sudo systemctl enable postfix
sudo systemctl start postfix

Step 3: Add GitLab Repository and Install GitLab

On Ubuntu/Debian:

curl -LO https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh
sudo apt install gitlab-ce

On CentOS/RHEL:

curl -LO https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh
sudo apt install gitlab-ce

Note : If the gitlab-ce installation will successfully done then we can see the gitlab logo as shown in the below image.

Installed Gitlab Community Edition

Step 4: Configure GitLab URL and Start Installation

  • Replace "http://gitlab.example.com" with your domain name or server IP address. If using an IP address, ensure you have a DNS record pointing to it.
  • After that step enter this command to restart your personal gitlab with this particular domain "sudo gitlab-ctl reconfigure" .

Step 5: Initial GitLab Configuration

  1. After installation, open your web browser and visit the GitLab URL you configured (e.g., http://gitlab.example.com).
  2. Set the password for the root user.
  3. Log in using the root account and the password you set.

Note : your initial password would be resides in /etc/gitlab/initial_root_password and username will be the root . After that we can login onto admin dashboard and then on it, we can change the username, email, password etc.

Dashboard of Admin

Step 6: Secure GitLab with SSL (Optional but Recommended)

For enhanced security, it is advisable to secure your GitLab instance using SSL certificates. You can obtain a free SSL certificate from Let’s Encrypt using Certbot:

On Ubuntu/Debian:

sudo apt install -y certbot
sudo certbot --nginx -d gitlab.example.com

On CentOS/RHEL:

sudo yum install -y certbot python2-certbot-nginx
sudo certbot --nginx -d gitlab.example.com

Step 7: Firewall Configuration

Ensure the necessary ports (HTTP: 80, HTTPS: 443, and SSH: 22) are open in your firewall to allow external access to GitLab.

Setting Up Email Notifications in GitLab Using Gmail

Enabling email notifications in GitLab allows you to receive important updates, such as merge request approvals, issue assignments, and pipeline status notifications. We can configure GitLab to use Gmail’s SMTP service to send email notifications. Follow the steps below to set up email notifications using Gmail:

Step 1: Generate Gmail App Password

To use Gmail’s SMTP service with GitLab, you’ll need to generate an “App password” to authenticate GitLab with your Gmail account. App passwords are used for applications that don’t support Google’s two-step verification.

  1. Go to your Google Account settings: https://myaccount.google.com/
  2. In the left navigation panel, click on “Security.”
  3. Under the “Signing in to Google” section, click on “App passwords.”
  4. Select “Mail” as the app and “Other (custom name)” as the device.
  5. Enter a custom name for the application (e.g., “GitLab SMTP”) and click on the “Generate” button.
  6. Google will generate a 16-character app password. Keep this password secure as you’ll need it later.

Step 2: Configure GitLab for Email Notifications

  1. Open the GitLab configuration file for editing. On Ubuntu/Debian, use the following command:
sudo nano /etc/gitlab/gitlab.rb

Find the configuration block for email settings and add the following lines:

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.gmail.com"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "your_email@gmail.com"
gitlab_rails['smtp_password'] = "your_generated_app_password"
gitlab_rails['smtp_domain'] = "smtp.gmail.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false

gitlab_rails['smtp_openssl_verify_mode'] = 'peer'

###! **Can be: 'none', 'peer', 'client_once', 'fail_if_no_peer_cert'**
###! Docs: http://api.rubyonrails.org/classes/ActionMailer/Base.html
gitlab_rails['gitlab_email_enabled'] = true

##! If your SMTP server does not like the default 'From: gitlab@gitlab.example.com'
##! can change the 'From' with this setting.
gitlab_rails['gitlab_email_from'] = 'pravegah@gmail.com'
gitlab_rails['gitlab_email_display_name'] = 'Pravegah Gitlab'
gitlab_rails['gitlab_email_reply_to'] = 'pravegah@gmail.com'

Replace “your_email@gmail.com” with your Gmail address and “your_generated_app_password” with the app password you generated in Step 1.

Save the configuration file and reconfigure GitLab to apply the changes:

sudo gitlab-ctl reconfigure

Step 3: Test Email Configuration

To verify that email notifications are working correctly, you can use the GitLab Rails console to send a test email:

Access the GitLab Rails console:

sudo gitlab-rails console

Send a test email:

Notify.test_email('recipient@example.com', 'Test Subject', 'Test Body').deliver_now

Replace “recipient@example.com” with your email address. You should receive a test email in your inbox.

Step 4: Enable Email Notifications in GitLab Settings

Log in to your GitLab instance as an administrator and navigate to “Settings” > “General” > “Email” to enable email notifications. Enter the “From email address” as your Gmail address.

Note: Gmail may have some restrictions on sending emails from new or less secure apps. If you encounter any issues, check your Gmail account settings and ensure that you have allowed access for “less secure apps.”

Conclusion:

Congratulations! You have successfully installing GitLab Community Edition on your personal server. GitLab provides a robust platform for managing your code repositories, collaborating with your team, and automating the software development lifecycle. By following this step-by-step guide, you can unleash the full potential of GitLab and enjoy seamless version control, issue tracking, and continuous integration for your projects. Happy coding!

This website stores cookies on your computer. Cookie Policy