Atlantic.Net Blog

How to Set Up GitLab on CentOS 8

Hitesh Jethva
by Atlantic.Net (64posts) under VPS Hosting
0 Comments

GitLab is a free, open-source, web-based version control platform that allows you to manage all your Git repositories from the centralized server. GitLab is a great alternative to Github, offering very useful features including code review, issue management, repository branching, merging, time tracking, and continuous integration and deployment. GitLab is specially designed for developers to create, review, and deploy their projects.

GitLab is available in three different editions: Community Edition (CE), Enterprise Edition (EE), and a GitLab-hosted version. You can install any of them depending on the requirements of your use case.

In this tutorial, we will show you how to install GitLab CE on CentOS 8.

Prerequisites

  • A fresh CentOS 8 VPS on the Atlantic.Net Cloud Platform.
  • A CPU with 2 cores to support up to 500 users.
  • At least 4GB of RAM to support up to 50 users.
  • A valid domain name pointed to your server IP.
  • A root password configured on your server.

Step 1 – Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing CentOS 8 as the operating system with at least 4GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Once you are logged into your CentOS 8 server, run the following command to update your base system with the latest available packages.

dnf update -y

Next, you will need to install some required dependencies on your system. You can install all of them with the following command:

dnf install curl policycoreutils python3-policycoreutils -y

Step 2 – Install GitLab CE

By default, GitLab is not available in the CentOS 8 default repository, so you will need to add the GitLab repository in your system.

You can install it with the following command:

curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | bash

Once the repository is added, you should get the following output:

Next, install GitLab CE by running the following command:

dnf install gitlab-ce -y

Once the installation has been completed successfully, you can proceed to the next step.

Step 3 – Secure GitLab with Let’s Encrypt

Next, you will need to set the GitLab URL and enable Let’s Encrypt integration. You can do it by editing the file /etc/gitlab/gitlab.rb:

nano /etc/gitlab/gitlab.rb

Change the following lines that match your domain name and enable Let’s Encrypt integration with your desired value:

external_url 'https://gitlab.example.com'
letsencrypt['enable'] = true
letsencrypt['contact_emails'] = ['[email protected]']  
letsencrypt['auto_renew'] = true
letsencrypt['auto_renew_hour'] = 12
letsencrypt['auto_renew_minute'] = 15
letsencrypt['auto_renew_day_of_month'] = "*/4"

Save and close the file when you are finished. Then, reconfigure GitLab CE with the following command:

gitlab-ctl reconfigure

This command will reconfigure GitLab and secure it with Let’s Encrypt SSL. Once the GitLab setup has been completed successfully, you should get the following output:

  * execute[reload prometheus] action run
    - execute /opt/gitlab/bin/gitlab-ctl hup prometheus
Recipe: monitoring::alertmanager
  * runit_service[alertmanager] action restart (up to date)
Recipe: monitoring::postgres-exporter
  * runit_service[postgres-exporter] action restart (up to date)
Recipe: monitoring::grafana
  * runit_service[grafana] action restart (up to date)
Recipe: nginx::enable
  * execute[reload nginx] action run
    - execute gitlab-ctl hup nginx
Recipe: letsencrypt::enable
  * ruby_block[display_le_message] action run
    - execute the ruby block display_le_message
Recipe: crond::enable
  * runit_service[crond] action restart (up to date)

Running handlers:
Running handlers complete
Chef Client finished, 609/1641 resources updated in 10 minutes 43 seconds

Warnings:
Environment variable LANG specifies a non-UTF-8 locale. GitLab requires UTF-8 encoding to function properly. Please check your locale settings.

gitlab Reconfigured!

Step 4 – Access GitLab Web UI

At this point, GitLab is installed and configured, and you can now access the GitLab UI by visiting the URL https://gitlab.example.com. You will be redirected to the password change screen as shown below:

Set the new password for the root user and click on the Change your password button. Once the password is changed successfully, you should see the GitLab login screen:

Enter root as your username, your specified password, and click on the Sign in button. You should see the GitLab dashboard in the following screen:

Step 5 – Disable User Sign Up

By default, GitLab allows new users to sign up, which is very dangerous for security reasons. It is recommended to disable user registration on the GitLab welcome page.

To disable User Sign Up, click on the Admin area as shown below:

Now, click on Settings in the left pane. You should see the following page:

Next, Expand the Sign-up restrictions. You should see the following page:

Next, uncheck Sign-up enabled button to disable User registration on the GitLab welcome page and click on the Save Changes button.

Next, log out of your GitLab dashboard. You should see the following screen:

As you can see, the tab for user registration is missing.

Step 6 – Automate GitLab Backup

You can take a complete backup of GitLab data with the following command:

gitlab-rake gitlab:backup:create

This command will take a complete backup of GitLab data and save it in the /var/opt/gitlab/backups directory. Once the backup has been completed successfully, you should get the following output:

2020-03-22 10:59:34 -0400 -- Dumping database ...
Dumping PostgreSQL database gitlabhq_production ... [DONE]
2020-03-22 10:59:37 -0400 -- done
2020-03-22 10:59:37 -0400 -- Dumping repositories ...
2020-03-22 10:59:38 -0400 -- done
2020-03-22 10:59:38 -0400 -- Dumping uploads ...
2020-03-22 10:59:38 -0400 -- done
2020-03-22 10:59:38 -0400 -- Dumping builds ...
2020-03-22 10:59:38 -0400 -- done
2020-03-22 10:59:38 -0400 -- Dumping artifacts ...
2020-03-22 10:59:38 -0400 -- done
2020-03-22 10:59:38 -0400 -- Dumping pages ...
2020-03-22 10:59:38 -0400 -- done
2020-03-22 10:59:38 -0400 -- Dumping lfs objects ...
2020-03-22 10:59:38 -0400 -- done
2020-03-22 10:59:38 -0400 -- Dumping container registry images ...
2020-03-22 10:59:38 -0400 -- done
Creating backup archive: 1584889178_2020_03_22_12.9.0_gitlab_backup.tar ... done
Uploading backup archive to remote storage  ... skipped
Deleting tmp directories ... done
done
done
done
done
done
done
done
done
Deleting old backups ... skipping
Backup task is done.

It is recommended to schedule backups with Cron so that you don’t need to run backups regularly.

You can schedule backups by editing the following file:

nano /etc/crontab

Add the following line to back up GitLab data every day at 8:00 PM:

0 20 * * * gitlab-rake gitlab:backup:create

Save and close the file when you are finished.

Conclusion

Congratulations! You have successfully installed and configured GitLab CE on CentOS 8 server. You can now host your own repository with GitLab and start collaborating with other developers today with GitLab on a VPS with Atlantic.Net!

Get A Free To Use Cloud VPS

Free Tier Includes:
G2.1GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G2.1GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2323 Bryan Street,

Dallas, Texas 75201

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources