Skip to content

Instantly share code, notes, and snippets.

@novalore
Last active December 31, 2015 22:19
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save novalore/8053095 to your computer and use it in GitHub Desktop.
Save novalore/8053095 to your computer and use it in GitHub Desktop.
A guide to install GitLab >6.0 on Debian 7 "Wheezy"

GitLab is a self hosted Git management software based on Ruby on Rails.

It is free software and that is always a plus!

This tutorial is heavily based on the excellent post at rosehosting.com and collects information I found in documentation and on the internet generally.

Note: We'll work in a root console using Bash

If you don't have an editor of choice install vim (it's great!)

  apt-get install vim

Then install a few useful packages:

  apt-get install dialog build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl git-core openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev python-docutils sudo

Your Python version has to be greater than 2.5 and lower than 3.0+

  python --version

now check if you can access python shell via ‘python2′:

  test ! -e /usr/bin/python2 && ln -s /usr/bin/python /usr/bin/python2
  python2 --version

(the version has, obviously, to be the same!)

Unfortunately the ruby version included in Wheezy is not the one we'd like to use, so we'll have to compile and install it from source:

 mkdir /opt/ruby
 cd /opt/ruby
 curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz | tar xz
 cd ruby-2.0.0-p353
 ./configure && make
 make install

Now you can use ruby to install the bundler ruby gem:

  gem install bundler --no-ri --no-rdoc

Then create git user and install gitlab-shell:

  adduser --disabled-login --gecos 'GitLab' git
  cd /home/git
  sudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.git
  cd gitlab-shell
  sudo -u git -H git checkout v1.8.0

Edit the configuration including your URL as gitlab_url instead of the default "http://localhost/"

  sudo -u git -H cp config.yml.example config.yml
  sudo -u git -H vim config.yml

Now that the shell is properly configured, we can run the install script for gitlab-shell

  sudo -u git -H ./bin/install

Then we need to install MariaDB as database server. Go to https://downloads.mariadb.org/mariadb/repositories/ and follow the istructions to be able to install deb packages from their repositories and them:

  apt-get install mariadb-server-10.0 mariadb-client-10.0 libmariadbclient-dev

When prompted insert a proper password for your administrator, then start using it

  mysql -u root -p
  MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS `gitlabDB` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
  MariaDB [(none)]> GRANT ALL ON `gitlabDB`.* TO 'gitlab'@'localhost' identified by 'INSERT_PASSWORD_HERE_PLEASE';
  MariaDB [(none)]> exit

Once the database has been created, proceed with the installation of GitLab:

  cd ../
  sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab
  cd gitlab/
  sudo -u git -H git checkout 6-4-stable

Edit the configuration including your URL as host instead of the default "localhost" and filling email_from and support_email with proper values

  sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
  sudo -u git -H vim config/gitlab.yml

Fix directory permissions:

  chown -R git log/ tmp/
  chmod -R u+rwX  log/ tmp/
  sudo -u git -H mkdir /home/git/gitlab-satellites
  sudo -u git -H mkdir tmp/pids/
  sudo -u git -H mkdir tmp/sockets/
  sudo -u git -H mkdir public/uploads
  chmod -R u+rwX  tmp/pids/ tmp/sockets/ public/uploads

Configure unicorn HTTP server - make sure you tune unicorn to suit your needs. be careful how much resources you allocate and actually have. you can always start with something like worker_processes 1 and timeout 120:

  sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
  sudo -u git -H vim config/unicorn.rb

Now configure git user's git configuration

  sudo -u git -H git config --global user.name "GitLab"
  sudo -u git -H git config --global user.email "gitlab@INSERT_YOUR_DOMAIN"
  sudo -u git -H git config --global core.autocrlf input

Edit database configuration (in "production" section) to setup connection to mysql and db, editing "database", "username" and "password" according to your configuration (in this example database is gitlabDB and username is gitlab)

  sudo -u git cp config/database.yml.mysql config/database.yml
  sudo -u git -H vim config/database.yml
  sudo -u git -H chmod o-rwx config/database.yml

Use ruby to initialize the database

  gem install charlock_holmes --version '0.6.9.4'
  sudo -u git -H bundle install --deployment --without development test postgres aws
  sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production

You have to answer ‘yes’ when asked "Do you want to continue (yes/no)?"

GitLab needs an init script in init.d

  cp lib/support/init.d/gitlab /etc/init.d/gitlab
  chmod +x /etc/init.d/gitlab
  update-rc.d gitlab defaults 21

then check gitlab application status and start it

  sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
  /etc/init.d/gitlab start

Install and configure Nginx:

  apt-get install nginx
  cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab

Edit the configuration (delete default_server if this is not the only website on your server, for example) and make sure to change server_name YOUR_SERVER_FQDN to your real url

  vim /etc/nginx/sites-available/gitlab
  ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
  service nginx restart

now you can point your browser to your domain and enjoy gitlab

username: admin@local.host

password: 5iveL!fe

Notes on GitLab customization

that's just a collection of notes, don't take it too seriously

  • Since 6.4 the Default project features settings section supports a visibility_level: keyword that can be set to "public", "internal" or "private" <- don't forget the quotes! (substitutes public: which was a bool).

Logo on the homepage (and custom text as well):

when editing the "Extra customization" section you have to uncomment sign_in_text if you want any of the following to work (yaml parsing seems to be very strict and an indentation level should never be neglected).

    ## Text under sign-in page (Markdown enabled)
    # sign_in_text: |
    #   ![Company Logo](http://www.companydomain.com/logo.png)
    #   [Learn more about CompanyName](http://www.companydomain.com/)

becomes...

    ## Text under sign-in page (Markdown enabled)
     sign_in_text: Put your custom text here (or leave | if you want)
        ![Company Logo](http://www.companydomain.com/logo.png)
    #   [Learn more about CompanyName](http://www.companydomain.com/)

Is there a setting to change logo in the upper left corner (the gitlab cat mascotte)?

@novalore
Copy link
Author

I'm currently trying to customize Company Logo on GitLab, but it seems to be more difficult than I thought ❗

It has surely something to do with white-spacing in .yaml files. I commented on issue https://github.com/gitlabhq/gitlabhq/issues/4262 to ask if someone knows better. We'll see...

@novalore
Copy link
Author

Since 6.4.3 gitlab-shell does not have to be in /home/git, but can be placed wherever you like. I should try that feature.

@xsharp
Copy link

xsharp commented Feb 11, 2014

  • step ?

sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production

@kpobococ
Copy link

While installing GitLab with your guide, specifically on the "bundle install" step, I got a following error:

Could not find modernizr-2.6.2 in any of the sources

Here's a solution I've found, if somebody else has the same error: http://stackoverflow.com/a/22827382

@vojtechmares
Copy link

Hello, I have small issue. When I run this command:
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production

SSH shows me this error:
root@arrow:/home/git/gitlab# sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
Could not find rake-10.1.0 in any of the sources
Run bundle install to install missing gems.

Can someone tell me how to fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment