GitLab Installation Tutorial Part 1

GitLab Installation Tutorial (Part1)

8 Apr 2016 11 min read

Well if you want on your own server a personal Git repository while using GitLab as repository platform, then you probably will face a problem of managing Gitlab, Nginx, and Plesk together.

So for successful GitLab installation follow our tutorial below.

Step 1 – Prerequisites

At the start, let’s make sure we have more or less fair condition.

There is a Linux CentOS v6.5 server with Plesk installed (was used version 12.5.30 as a ref., but the procedure has also been tested on version 12.0.18) and you are root on the server.

Primarily it’s necessary to install the latest version of Git (now from PUIAS Computational repository:

$ wget -O /etc/yum.repos.d/PUIAS_6_computational.repo
wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-puias rpm 
--import /etc/pki/rpm-gpg/RPM-GPG-KEY-puias
sudo yum install git

or, for the instant version (now 2.6.1):

yum install gettext-devel expat-devel curl-devel zlib-devel openssl-devel cd /tmp
wget tar xzvf git-2.6.1.tar.gz cd git-2.6.1 make 
prefix=/opt/git all make prefix=/opt/git install export PATH="/opt/git/bin:$PATH" ln -s /opt/git/bin/git /usr/bin/git

Check its installation with:

git --version

Since Git was created for Ruby v2.0+, the next step is to install the prerequisites, the OpenSSL extension and Ruby for current version (2.1.2):

yum install ruby

Or such command for the previous one:

yum install gcc zlib zlib-devel openssl-devel mkdir /tmp/ruby && cd /tmp/ruby curl --progress | tar xz cd ruby-2.1.2/ext/openssl/ ruby extconf.rb make 
top_srcdir="../../" sudo make install top_srcdir="../../" cd ../../ ./configure --disable-install-rdoc make sudo make 
prefix=/usr/local install

Then use the gem command to install Bundler, a dependencies manager for Ruby:

gem install bundler --no-doc

Step 2 – GitLab

Now when all prerequisites done, it’s important to add the server for the GitLab CE (Community Edition) package with:

curl | sudo bash

and at last set up the package with:

sudo yum install gitlab-ce

At the end of GitLab installation on your server , in the /var/opt/gitlab/ folder it  have to be adapted due to our needs.

In case you want your Git repository to be available at the address , then you have to edit the /etc/gitlab/gitlab.rb file and change the following values (above each of them we put a note with the meaning):

# External URL for the GitLab repository external_url '' # Completely disable GitLab's Nginx, 
since we're going to use the Plesk one nginx['enable'] = false # Sets server SSH port 
gitlab_rails['gitlab_shell_ssh_port'] = 22

To use GitLab with SSL protocol it’s necessary to change external_url and add an option as below:

external_url '' nginx['listen_https'] = false # to communicate with GitLab Nginx internally 
over HTTP, even if external_url is in HTTPS nginx['redirect_http_to_https'] = true # redirects all traffic to HTTPS

Specify HTTPS port as part of the external_url when it’s necessary to use it other than the default (443):

external_url ''

Since Apache cannot connect to a UNIX socket but instead need to be connected to a TCP Port, it’s important to verify your GitLab version and if it’s 8.0.x or 8.1.x, then you must also change the settings for the new gitlab-git-http-server:

gitlab_git_http_server['listen_network'] = "tcp" gitlab_git_http_server['listen_addr'] = "localhost:8181"

Don’t pay attention to configure above gitlab_git_http_server when using GitLab 8.2, and just put down:

gitlab_workhorse['listen_network'] = "tcp" gitlab_workhorse['listen_addr'] = "localhost:8181"

Supposing you need GitLab to send you emails, edit in the same file also SMTP server settings by typing in the server’s host (in our case, port (usually 25, if you do not use SSL/TLS) username and password to be used and authentication type (“plain” in our example):

gitlab_rails['gitlab_email_enabled'] = true gitlab_rails['gitlab_email_from'] = '[email protected] ' 
gitlab_rails['gitlab_email_display_name'] = 'wdscode Git Repository' gitlab_rails['gitlab_email_reply_to'] = 
'[email protected]' gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "" 
gitlab_rails['smtp_port'] = 25 gitlab_rails['smtp_user_name'] = "[email protected]" gitlab_rails['smtp_password'] = 
"yourpassword" gitlab_rails['smtp_domain'] = "" gitlab_rails['smtp_authentication'] = "plain" 
gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = false 
gitlab_rails['smtp_openssl_verify_mode'] = 'none'

To move data folder in your virtual host’s one:

git_data_dir "/var/www/vhosts/wdscode.loc/git.wdscode.loc/git-data"

To move uploads folder as well:

gitlab_rails['uploads_directory'] = "/var/www/vhosts/"

If you want to set backup folder and schedule:

gitlab_rails['backup_path'] = "/var/www/vhosts/" gitlab_rails['backup_keep_time'] =
 604800 # Limits backups lifetime to 7 days (604800 seconds)

Now reconfigure and start GitLab with previous settings using the command:

sudo gitlab-ctl reconfigure

Take notice that if right permissions are not set, those folders won’t be backupped by Plesk, so be careful when moving GitLab folders in the virtual host’s ones.

Because GitLab works with git user and group, and it enforces 700 as permissions on both data (/var/opt/gitlab/git-date/) and backup (/var/opt/gitlab/backups) folders, the fastest way to solve is to change folders permissions after each reconfiguration of GitLab (gitlab-ctl reconfigure), so that Plesk can back them up.

You can do it by following this command:

chmod a+x -R /var/www/vhosts/ chmod a+x -R 
/var/www/vhosts/ chmod a+x -R /var/www/vhosts/
ERP development final cta

Get a Custom Solution with Web Design Sun

At Web Design Sun, we specialize in building web applications for clients in every business and industry.  If you’re interested in custom applications for your business, contact us today.

Contact us today to get started

More From Blog

Key Points in B2B Website Design

Business-to-business (B2B) web design is a different undertaking than business-to-consumer (B2C) web design. This means the behavior of business-to-business website visitors isn’t the same as the behavior of B2C visitors.
8 Jan 2018 21 min read

8 Web Development Trends to Watch Out for in 2023

Stay ahead of the game in web development with our guide to 8 key trends for 2023. From artificial intelligence and machine learning to serverless computing and the Internet of Things, this blog post covers the technologies and techniques that you need to know to create the best possible user experience.
6 Jan 2023 8 min read

How Much Does It Cost To Build a Web Application?

You want to build a web application, but you’re worried about the cost. If that sounds familiar, we understand your fear. We’ve wrote this article to show that there are ways to control the costs, and it’s possible to get a custom web application that doesn’t break the bank.
19 Nov 2021 23 min read