Install and config gitlab-ce

Install and config gitlab-ce

(2017-04-02 +0800)

  • Host: ubuntu 16.04.2 or … LTS
  • Gitlab: gitlab-ce



Check whether your server meets the hardware requirements.
GitLab packages are built for 64bit systems.
For 32bit OS, consider alternative installation methods.

Install and configure the necessary dependencies

If you install postfix to send email please select ‘internet site’ during setup.
instead of using Postfix you can also use Sendmail
or configure a custom SMTP server
and configure it as an SMTP server.

Here use Postfix: config is DOMAIN of the administrator email!!

sudo apt-get install curl openssh-server ca-certificates postfix

# Simple reconfigure postfix by reinstall
sudo apt-get purge postfix
sudo apt-get install postfix

Add the gitlab package server and install the package

# NOT by this mirror
curl -sS | sudo bash

curl 2> /dev/null | sudo apt-key add - &>/dev/null
deb xenial main
to: /etc/apt/sources.list.d/gitlab-ce.list

# then
sudo apt-get update
sudo apt-get install gitlab-ce


Fixed !!
sudo dpkg-divert --local --rename --add /sbin/initctl
sudo ln -s /bin/true /sbin/initctl
NO login git account!!
sudo useradd -r git -s /usr/sbin/nologin
sudo apt-get install -y postgresql postgresql-client libpq-dev postgresql-contrib
sudo -u postgres psql -d template1 -c "CREATE USER git CREATEDB;"
sudo -u postgres psql -d template1 -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
sudo -u postgres psql -d template1 -c "CREATE DATABASE gitlabhq_production OWNER git;"
sudo -u git -H psql -d gitlabhq_production
sudo -u postgres psql -d template1 -c "ALTER ROLE git WITH PASSWORD 'YOUR_PASSWD';"
With external HTTP server

Apache or ngnix …: configure rewrite, redirect!

Apache2 and “redirect http requests to https”
and “Using a non-bundled web-server”…

TODO: ngnix


  • NO SSL + with prefix apache configuration:
  • SSL + with prefix apache configuration TODO
  • SSL + NO prefix apache configuration TODO
Or without external HTTP server

Just use workhorse, e.g. ...:8181

Reconfigure gitlab

Configuring the external URL for GitLab

Configuring a relative url for gitlab

# Set the external_url in /etc/gitlab/gitlab.rb:
external_url ""
# My
external_url ""

# Reconfigure GitLab for the changes to take effect:
sudo gitlab-ctl reconfigure

# Restart gitlab in case you shut down unicorn and sidekiq in the first step:
sudo gitlab-ctl restart

Example /etc/gitlab/gitlab.rb
TODO more


sudo gitlab-ctl reconfigure


sudo gitlab-ctl restart

Browse to the hostname and login

On your first visit,
you’ll be redirected to a password reset screen to provide the password
for the initial administrator account.
Enter your desired password and you’ll be redirected back to the login screen.

The default account’s username is root.
Provide the password you created earlier and login.
After login you can change the username if you wish.

For configuration and troubleshooting options please see the
Omnibus GitLab documentation
If you are located in China, try using


git submodule

git submodule

set -x
git pull
if [ $? -ne 0 ]; then echo "FAIL!!"; exit 1; fi
git submodule init
if [ $? -ne 0 ]; then echo "FAIL!!"; exit 1; fi
git submodule update
if [ $? -ne 0 ]; then echo "FAIL!!"; exit 1; fi
make OYW_HASQT=1 OYW_CCC=1 clean
if [ $? -ne 0 ]; then echo "FAIL!!"; exit 1; fi
if [ $? -ne 0 ]; then echo "FAIL!!"; exit 1; fi
echo "Done"
  • Below are examples

add submodule

$ git submodule add modules/cppnetwork

$ cat .gitmodules
[submodule "modules/base64ende"]
    path = modules/base64ende
    url =
[submodule "modules/checksum"]
    path = modules/checksum
    url =
[submodule "modules/cppnetwork"]
    path = modules/cppnetwork
    url =

add submodule url (from .gitmodules) to .git/config 以及后续 submodules clone

Set url(s):
git submodule init
git submodule update

brand-new clone master and sub modules:

git clone --recursive


git submodule
git submodule status
git submodule status --recursive

 38837fa4806b58bc17a002c5a1db36b95b1be7e5 modules/base64ende (heads/master)
 fdbf9709c66cb027e44b92cf12b9f3f5e893083e modules/checksum (heads/master)
 cc1977851ebbf2c72d60d88d49161be43e5f3796 modules/cppnetwork (heads/master)

get remote latest need by master

git submodule update --remote

git submodule update --remote modules/cppnetwork


git submodule foreach 'git checkout master'

git submodule foreach 'git pull'

update master deps.

  • 1 git submodule foreach 'git pull'
  • 2 add and commit