;

How to Install GitLab on CentOS 7

Try it in our public cloud & Get $5 Credit
CLAIM NOW

How to Install GitLab on CentOS 7

GitLab is a popular Git repository hosting service written in the programming language Ruby that allows for collaborative revision control on coding projects with a cloud-based, streamlined work flow. GitLab is similar to the equally prevalent Git-repository hosting service GitHub, but more developed in its features as a platform that also provides enhanced security and project flexibility. These security features include an increased flexibility when managing permissions, the ability to protect branches, and additional authentication features to allow security when coding at the fine-granular level. Luckily for our purposes, GitLab is provided in two main versions, the Enterprise Edition and the Community Edition, alongside with an additional online platform that allows for a simple introduction to how GitLab operates. While both the main editions pack a punch in features, the Community Edition has the benefit of being free and thus being a good way to explore the benefits of integrating GitLab into your landscape.

install gitlab

This tutorial will show you how you can install GitLab on your CentOS 7 server so that you too can experience its benefits.

Getting Started

Before proceeding with the steps in this guide, make sure you have the following:
• 1 Node (Cloud Server or Dedicated Server) running a clean installation of CentOS 7.
• Root access to the node or superuser permissions.

Please ensure that you also have root access or your user has sudo permissions.

Tutorial

As a matter of good server management, it is important to keep your server updated on the latest packages available for installation. Prior to beginning the installation process of GitLab, we will first ensure that the CentOS 7 server has the latest information about packages using the help of the default package manager yum as root. If you are not the root user but have superuser privileges, append sudo to the front of each command meant to be run as root. Using sudo will allow you to run that particular line as root when needed.

yum update -y

GitLab has two main prerequisite packages that must be installed before GitLab can be obtained and configured for your system. The first package, postfix, is a popular mail transfer service agent, and the second, openssh-server, installs server application for the OpenSSH protocol. Like in this case, multiple packages can be easily installed together in one line by using the yum syntax:

yum install [package1] [package2]

Following this syntax, we will install both prerequisites at the same time. By appending the -y flag to yum install …, you are able to skip the “Yes to continue” prompt during the installation of each package:

yum install postfix openssh-server -y

We will need both Postfix and the OpenSSH server to be running for the rest of the guide. We can turn on the services using the command systemctl, which interacts with the system to manage services (processes) running on it.

systemctl start sshd
systemctl start postfix

You can furthermore ensure that these services are always running on boot by using systemctl with the option enable. This means that you will no longer have to manually enter the start commands to run the services, rather, they will be started automatically for you each time your CentOS 7 boots. Execute the systemctl enable command for both Postfix and the OpenSSH server:

systemctl enable postfix
systemctl enable sshd

Depending on the age of your server, you may also be missing more packages that are needed within this tutorial to install GitLab, but are not technically GitLab prerequisites. These two packages respectively will handle downloads as well as some other basic server policy functions that are useful/required for many other packages.

yum install curl policycoreutils -y

If you have not made any custom configurations to the firewall on your server, the firewall service firewalld will be up and running to protect your server. While the protection is very useful, we will have to add the exceptions for HTTP and HTTPS access to the firewall configuration to proceed:

firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https

Having added the exceptions, reload the firewalld service using the service manager in order for the changes to take into effect:

systemctl reload firewalld

Having configured your firewall, the CentOS 7 server is now ready to install GitLab. First, obtain the repository using the curl package installed above. curl will save the url location to a local file with the same name as specified by the -O flag.

curl -O curl -O https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh

When you have downloaded the package you want, complete the repository installation by executing:

sh script.rpm.sh

Now you are free to actually install the community edition of the GitLab package, named gitlab-ce. This command will install the latest version available in the fetched repository at the time using yum:

yum install gitlab-ce -y

You will know that the installation process is successful when you see the following output on your screen:

gitlab: Thank you for installing GitLab!
gitlab: To configure and start GitLab, RUN THE FOLLOWING COMMAND:
sudo gitlab-ctl reconfigure
gitlab: GitLab should be reachable at...

Just as the prompt suggestions upon completion, now we will configure GitLab to work on your server. Start the configuration process using the gitlab-ctl command:

gitlab-ctl reconfigure

After having run the command, navigate to your GitLab online. This is done easily by opening a browser page to the following URL, replacing the address 10.10.0.35 with your own IP address:

http://10.10.0.35/

When the browser opens the link, you will see the landing page for GitLab. This page includes a brief blurb about GitLab, as well as a prompt to register or sign into GitLab such as the following:

GitLab Community Edition
Open source software to collaborate on code
Existing user? Sign in. New user? Sign up.

As this is the first time accessing GitLab, you will need to set a new password and username for the GitLab root user by registering those credentials. You will need to use this root username and password each time to access GitLab, so be sure to memorize them or keep them in a safe place.

Upon successful login, you will see the GitLab index page, which will portray all projects you have currently linked.

Conclusion

With the easy and quick setup for GitLab, you are now ready to start exploring! Check out the GitLab website for more information about what GitLab can do, and be sure to share this guide with your friends if you enjoyed it.