1. Home
  2. VPS
  3. Tutorials
  4. How to install Gitlab on a CentOS 7 VPS

How to install Gitlab on a CentOS 7 VPS

There are many competitors in the field of git repository hosting, such as Github, Bitbucket and Gitlab. Those services are great as an hosted service (Github is not free for private repositories). However, if you want to host your own instance and know where your data is, the only free solution is the community edition of Gitlab.

With Gitlab you will get access to almost any feature such as an issue tracker, milestones, groups and projects. Upgrades are per user (and not per pack, like Bitbucket does) and are fairly priced. Gitlab is also great for having developers all around the world in the enterprise version.

How to install Gitlab

First, spin up a new VPS based on CentOS 7 using the VPS manager. Installation of a new VPS will only take a few clicks. Do not forget to remember the root password as we will use this to ssh to the server. Also make sure that the hostname resolves in the IP of the server as this will be used for Gitlab. You can change the name later to a different name.

Run the following commands

yum update -y
firewall-cmd --permanent --add-service=http
systemctl reload firewalld
Continue quickly after running gitlab-ctl reconfigure

Make sure that you can continue directly when gitlab-ctl has completed. Anyone who knows the hostname will be able to set the root password for the main account in Gitlab. In case you are unable to do so, do not continue with installing Gitlab on your VPS.

Run the following command to install Gitlab:

curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | bash
yum install gitlab-ce -y
gitlab-ctl reconfigure

Configure root account for Gitlab

Go to the hostname of your server. Gitlab will open with a password recovery page where you can enter the password for the main user account with admin privileges. The default username is root.


Disable open registration

WARNING: Registration is open by default

Anyone who knows the URL to your installation can register by default. To disable this, click on the wrench. Next, click on the cog -> “Settings”. Scroll down to “Sign-up enabled” and disable the checkbox. Click on “Save” to make the setting active.

Tips for Gitlab

Now you have running your own Gitlab instance, we recommend that you secure your server with at least a tool like CSF. Furthermore it is important to secure your server with https. Continue with our article about how to install Let’s Encrypt with Gitlab.

Updated on May 6, 2017

Was this article helpful?

Related Articles