Why install GitLab on your VPS?
GitLab is an open source application that offers a graphical user interface (GUI) to help manage Git repositories. It includes lots of features, such as issue tracking and easy pull requests and merges.
If you don't want to pay for GitHub’s or Bitbucket’s paid features, or if you want to maintain full control over your codebase, then a self-hosted GitLab installation is a great option.
Today, we'll walk you through how to install GitLab on your VPS running Ubuntu, Debian or CentOs.
Prerequisites for GitLab installation:
- A VPS running Ubuntu 16.04/18.04, Debian 8/9/10, or CentOS 7
- A regular (non-root) account with sudo privileges. See our SSH keys tutorial for more information.
- A VPS that meets the hardware requirements. Any 8GB or larger VPS from SSD Nodes should to the trick.
Step 1: Installing dependencies
To get ready to install GitLab on your VPS, you need to install some dependencies.
Luckily, they’re available in default repositories:
Ubuntu 16.04/18.04, Debian 8/9/10
$ sudo apt install curl openssh-server ca-certificates postfix
Centos 7
$ sudo yum install curl policycoreutils openssh-server openssh-clients
$ sudo systemctl enable sshd
$ sudo systemctl start sshd
$ sudo yum install postfix
$ sudo systemctl enable postfix
$ sudo systemctl start postfix
$ sudo firewall-cmd --permanent --add-service=http
$ sudo systemctl reload firewalld
Step 2: Installing GitLab on VPS
First, you need to add the GitLab repository, and then install the package.
Note: We recommend that you check all scripts you're executing as the sudo user before you execute them. You can find GitLab's install script here.
Ubuntu 16.04/18.04, Debian 8/9/10
$ curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
$ sudo apt install gitlab-ce
CentOS 7
$ curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
$ sudo yum install gitlab-ce
This operation might take a bit to complete.
When it’s done, you’ll see the following output:
*. *.
*** ***
***** *****
.****** *******
******** ********
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,,
,*,.
_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __
/ /_/ / / /_/ /___/ /_/ / /_/ /
____/_/__/_____/__,_/_.___/
gitlab: Thank you for installing GitLab!
gitlab: To configure and start GitLab, RUN THE FOLLOWING COMMAND:
sudo gitlab-ctl reconfigure
Step 3: Run and configure GitLab
You've now installed GitLab on your VPS, so let's fire it up and make sure it’s running smoothly.
See that command above? Give it a whirl.
$ sudo gitlab-ctl reconfigure
You'll see quite a bit of output as the script operates.
If you need to make any changes to the external URL, for example, or any of the other configuration options, you can edit the gitlab.rb
script and then re-run the configuration.
$ sudo nano /etc/gitlab/gitlab.rb
$ sudo gitlab-ctl reconfigure
IMPORTANT: If you followed our previous tutorial on installing a LEMP stack, you will need to configure GitLab to work with your existing nginx installation. GitLab has detailed instructions on how to configure the connection in their documentation.
Step 4: Log into GitLab for the first time
Once you’ve made any changes to GitLab’s configuration and it’s up and running without errors, you can direct your web browser to the default external URL, or the one you chose.
If you see the following page, you’ve successfully installed GitLab!
Provide a password for the administrator account when prompted.
Then enter the password you choose, and then you’ll be directed to a login screen.
The administrator username is root
by default. Enter that plus the password you just created, and you’ll be ready to start managing your Git repositories directly on your own VPS!
A note about tutorials: We encourage our users to try out tutorials, but they aren't fully supported by our team—we can't always provide support when things go wrong. Be sure to check which OS and version it was tested with before you proceed.
If you want a fully managed experience, with dedicated support for any application you might want to run, contact us for more information.