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

How To Develop Widgets For Gutenberg Using ACF

Gutenberg is a new WordPress editor for posts and pages, built on the principles of builders, allows you to write custom page builder elements. Using the ACF plugin, you can very simply make a widget of any type. And here we'll show how.
1 May 2020 6 min read

Handling Inbound Emails in Laravel

Setting up sending emails using laravel is very simple, but what if you need to receive incoming emails. n this case, use the Laravel Mailbox package. Here we want to tell about the process of setting up incoming messages using Sendgrid.
19 Mar 2020 4 min read

Best AI Services for Generation Content

Artificial Intelligence (AI) has come a long way in recent years and has proven to be a valuable tool for content generation. With the help of AI, businesses and individuals can now generate high-quality content in a fraction of the time it would take to do it manually. In this blog post, we will take a look at some of the best AI services currently available for content generation and how they can help you save time and effort.
23 Jan 2023 11 min read