[Guide] Install GitLab in Ubuntu server

GitLab is a web-based Git repository manager with some useful tools like board, wiki, issue tracking,… The community edition comes with an open source license and this platform is developed by GitLab Inc.
It’s possible to create a free account in their website and use their platform completely free. But you can also have the necessity to install it in a private machine for example because you have confidential projects where you must keep all data in a local machine.

In this guide, I’ll show you how you can install it in a own machine running Ubuntu Server 16.04 LTS…

Install dependencies

First of all, you need to install some dependencies for gitlab.
# sudo apt-get install curl openssh-server ca-certificates postfix nodejs

Install and configure GitLab

Add the GitLab package server and install the package
# curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
# sudo apt-get install gitlab-ce

Now you can configure and restart GitLab with:
# sudo gitlab-ctl reconfigure

At this point, you can open your gitlab in a browser and create an admin account. Example: mygitlab.crypted2.com

Useful configs

If you have a custom ssh port, you can correct the configuration of GitLab editing the file: /etc/gitlab/gitlab.rb
gitlab_rails[‘gitlab_shell_ssh_port’] = 22
gitlab-ctl reconfigure

If you forget the administrator password, you can reset it following the official guide: https://docs.gitlab.com/ee/security/reset_root_password.html

Nginx: Use your previous installation

GitLab uses the webserver nginx as default. If you have already an installation of nginx in your machine, you can keep using and you need just to edit some configs in GitLab.

Edit the file: # sudo nano /etc/gitlab/gitlab.rb

Search these lines and edit like this example:

external_url ‘https://git.crypted2.com’

nginx[‘enable’] = false
nginx[‘listen_port’] = 80
nginx[‘listen_https’] = false
nginx[‘proxy_set_headers’] = {
“X-Forwarded-Proto” => “https”,
“X-Forwarded-Ssl” => “on”
}

web_server[‘external_users’] = [‘www-data’]

Now you can clear the cache and reload GitLab, so it will load the new configs:
# sudo gitlab-rake cache:clear
# sudo gitlab-ctl stop
# sudo gitlab-ctl reconfigure
# sudo gitlab-ctl start

Nginx: Enable SSL for gitlab

Reference Link: https://www.phusionpassenger.com/library/install/nginx/install/oss/xenial/

Install our PGP key and add HTTPS support for APT:
# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
# sudo apt-get install -y apt-transport-https ca-certificates

Add our APT repository:
# sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger xenial main > /etc/apt/sources.list.d/passenger.list'
sudo apt-get update

Install Passenger + Nginx:
# sudo apt-get install -y nginx-extras passenger

Edit /etc/nginx/nginx.conf and uncomment include /etc/nginx/passenger.conf;

Some steps are missing, for example the configurations of nginx for the activation of the subdomain for GitLab. But this guide is focused to have the main steps to install the platform GitLab.
Leave us your feedback and help us to improve our posts.

Thank you !

Add a comment

*Please complete all fields correctly

Related Blogs

Posted by misterioso | January 6, 2018
[Guide] Install Pure-FTPd in Ubuntu server
Pure-FTPd is a free (BSD), secure, production-quality and standard-conformant FTP server. It doesn’t provide useless bells and whistles, but focuses on efficiency and ease of use. It provides simple answers...
Posted by misterioso | January 6, 2018
[Guide] Install NGINX in Ubuntu server
NGINX is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. NGINX is known for its high performance, stability, rich feature set, simple...