How to Install GitLab on Ubuntu 16
GitLab is an online hosting and management platform for projects that use the Git revision control system. Like GitHub, GitLab provides many of the same features for managing repositories, but differs mainly in its handling of security processes. The unique security features of GitLab make it a popular choice for both companies and security-minded individuals. These features include the ability to have highly flexible control over permissions for all aspects of the repository, the notion of protected branches, as well as additional authentication features. Officially released in three different versions, GitLab is available specifically for enterprise use, free use, as well as hosted online to experiment with.
If you are interested in installing GitLab on your Ubuntu 16 server, this tutorial will go through the steps required to install the free Community Edition of GitLab.
Getting Started
Before proceeding with the steps in this guide, make sure you have the following:
• 1 Node (Cloud Server or Dedicated Server) running Ubuntu 16.
• Root access to the node or superuser permissions.
Superuser privileges are given in the configuration file for the command sudo and allow your user to act as root. If you will proceed as a non-root user with superuser (also known as sudoer) permissions, you will need to append the text sudo to the start of each command.
Tutorial
This guide will make heavy usage of the native Ubuntu package manager apt, which is responsible for package update and installation. Before we can install any prerequisites for GitLab, or GitLab itself, we will need to update the local package index for apt to give it the latest information concerning available packages. Run the apt-get command as root or with sudo:
apt-get update
Having fetched the new package information, you can also upgrade the existing packages on your system to their latest versions if available. If you would like to do this, you can again use apt-get with the upgrade option:
apt-get upgrade
Next, with apt, we can install the prerequisite packages for using GitLab. These packages include Postfix, a mail client, and OpenSSH, to allow secure access using SSH to your server. You will also need the package for Curl, a web utility that can download files, and a certificates package that is used to install common CA certificates. apt is useful in this case as it allows multiple package installation at once, so that you don’t have to execute four different apt commands by using the syntax:
apt-get install [package_1] [...] [package_n]
Run apt-get with the required packages using the above syntax in order to download Postfix, OpenSSH, CA Certificates, and Curl:
apt-get install curl openssh-server ca-certificates postfix
There is a high probability that you already have several of the prerequisite packages already installed on your server, as they are prerequisites for a large variety of other applications than GitLab. In this case, the above command will also update the installed packages for you.
To start and enable to prerequisite packages OpenSSH and Postfix to run on boot, execute the following four commands:
service sshd start
service postfix start
update-rc.d sshd enable
update-rc.d postfix enable
With the prerequisite packages installed, you are now ready to actually install GitLab on your Ubuntu 16 server. Use the utility Curl with the -O flag in order to download the installation script from the GitLab repository to file in the local directory with the same name as the remote. The -L flag is used for extra protection that in the case that the server reports the requested GitLab page moved to a different location, Curl will try to redo the request to the new location to fetch the file.
curl -LO https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh
When the download of the file completes, you will need to run the installer using the language interpreter for Bash in the local directory:
bash script.deb.sh
The installation script, when complete, will have configured your server to use the GitLab-maintained package repository for GitLab with the native Ubuntu package manager apt. Thanks to this installation script for the repository, you can then install the actual GitLab package in the usual way using apt. This package is a special type of package known as an Omnibus full-stack installer, and will handle the remainder of the components that go into GitLab such as Ruby, Git, and Nginx.
apt-get install gitlab-ce
To finish configuring GitLab and get it running on your system once the Omnibus package installation is complete, the gitlab-ctl command is provided by the installed GitLab package. Execute it using the option reconfigure:
gitlab-ctl reconfigure
When GitLab is started up, you will be able to access it on your server using your browser. Navigate to the following URL, replacing the tutorial IP address with the address of your Ubuntu 16 server. If you have a domain name for your server, you can use that instead of the IP address.
http://10.10.0.35
On the first visit, the GitLab landing page will prompt you to change the GitLab administrator user’s password. Set the password for the administrative account and let the page reload to the landing page again. By default, the name of the administrative user will be “root,” but you can change this after login. Sign in with the credentials you just set in order to start using GitLab.
Conclusion
Thanks to the Omnibus GitLab package, this installation process is easy and quick to execute, leaving you ready to experience the multitude of GitLab features. You can find more information about what you can do now that GitLab is installed by exploring the GitLab website. If you found this guide useful, share it with your friends!