Set up your own GitLab instance on a Debian 7 (Wheezy) server
Content on this page is probably outdated and represents my personal knowledge, feelings and understading of things at that time .
After searching the web for a good (read: easy) way of installing GitLab on my Debian 7 (Wheezy) VPS I decided to go with the official instructions. But as usuall I had to make due with a bit of improvisation and therefore I’m writting down this modified quick’n’dirty version.
1. DependenciesIt's always good to update your machine prior doing anything major.
root # apt-get update root # apt-get upgradeNote: I'm usually running my systems without sudo. This guide will presume you su-ed to root and are using sudo only to act as the git user.
root # apt-get install sudoNow with the real dependencies:
root # apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotateMake sure you have installed Python version between 2.5 and 3.0 - by default wheezy comes with python 2.7 and that's good. Also it looks like python2 needs to be symlinked to python, which again by default should be a go. The check:
user $ python --version user $ python2 --versionWe also need git 1.7.10 or higher, which again by default should be ok. To install:
root # apt-get install git-coreAnd to check the version:
user $ git --versionYou will also need to have the mail sending installed and setup. This is way out of scope of this blog post. Next up is ruby. The official documentation suggest compiling it yourself, but there's no need, wheezy packs ruby (1.9.1 as of this writing) and again, this should be all ok. To install:
root # apt-get install ruby ruby-devTo check:
user $ ruby --version
System usersAdd a user named "git" under which the whole sheebang will run:
root # adduser --disabled-login --gecos 'GitLab' git root # sudo -u git -H git config --global user.name "GitLab" root # sudo -u git -H git config --global user.email "gitlab@localhost" root # sudo -u git -H git config --global core.autocrlf input
GitLab shellAs of this writing the latest gitlab shell is version 1.8.0 - check it and correct the branch part in the second command (-b v1.8.0):
root # cd /home/git root # sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-shell.git -b v1.8.0 root # cd gitlab-shell root # sudo -u git -H cp config.yml.example config.ymlNow you'll need to edit the configuration. Bare minimum is editing of "github_url" which has to be a dedicated domain/subdomain and cannot be a subdirectory. After that we'll install the GitLab shell.
root # sudo -u git -H editor config.yml root # sudo -u git -H ./bin/install
DatabaseGitLab supports MySQL and PostgreSQL databases. The setup is nicely documented GitLab databases documentation
GitLabAs with GitLab Shell you'll need to check the latest stable branch of GitLab in the source and replace the 6-4-stable part in the second commend:
root # cd /home/git root # sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 6-4-stable gitlab root # cd gitlabThat'll check out the latest code and now you'll need to configure it. Again, the bare minimum configuration is the domain/subdomain (host directive near the top).
root # cd /home/git/gitlab root # sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml root # sudo -u git -H editor config/gitlab.ymlNext there's a bunch of checking/setting stuff that should already be done, but newertheless:
root # chown -R git log/ root # chown -R git tmp/ root # chmod -R u+rwX log/ root # chmod -R u+rwX tmp/ root # sudo -u git -H mkdir /home/git/gitlab-satellites root # sudo -u git -H mkdir tmp/pids/ root # sudo -u git -H mkdir tmp/sockets/ root # chmod -R u+rwX tmp/pids/ root # chmod -R u+rwX tmp/sockets/ root # sudo -u git -H mkdir public/uploads root # sudo chmod -R u+rwX public/uploadsThere, a lot of groundwork done. Now we need to copy the example unicorn configuration and edit it (I didn't edit anything if I'm not mistaken, but ymmv):
root # sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb root # sudo -u git -H editor config/unicorn.rbNext up is the Rack attack config:
root # sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb root # sudo -u git -H editor config/initializers/rack_attack.rbNext up on the configuration is the database config. Ofcourse you need to configure the correct access credidentials. For MySQL:
root # sudo -u git cp config/database.yml.mysql config/database.ymlFor PostgreSQL:
root # sudo -u git cp config/database.yml.postgresql config/database.ymlAnd edit config and make it read to git only afterwards:
root # sudo -u git -H editor config/database.yml root # sudo -u git -H chmod o-rwx config/database.ymlNext up are the gems, I suggest you go make yourself a coffie while this runs: For MySQL:
root # cd /home/git/gitlab root # sudo -u git -H bundle install --deployment --without development test postgres awsFor PostgreSQL:
root # cd /home/git/gitlab root # sudo -u git -H bundle install --deployment --without development test mysql awsAfter that's done, we need to initialize the database and activate advanced features (oh my!). You'll need to follow the on-screen instructions and mark down the login.
root # cd /home/git/gitlab root # sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=productionThere we're almost done. Now we need to compile the assets:
root # sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
Debian/Linux support stuffNote: Most of the instructions that follow are for the straightforward installation as described above and need some tweaking if you have a special case. First we'll set the init script and set it so that GitLab will start on boot:
root # ln -s /home/git/gitlab/lib/support/init.d/gitlab /etc/init.d/gitlab root # update-rc.d gitlab defaults 21 root # service gitlab startNext up is Logrotate:
root # ln -s /home/git/gitlab/lib/support/logrotate/gitlab /etc/logrotate.d/gitlabNow you can check the application status (also handy later on):
root # cd /home/git/gitlab root # sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=productionThe final thing to do is to set up the nginx web server, we only skim this part, because there're a lot of good tutorial regarding this (you'll need to replace the hostname/subdomain to match what you used above).
root # apt-get install nginx root # cp /home/git/gitlab/lib/support/nginx/gitlab /etc/nginx/sites-enabled/gitlab root # edit /etc/nginx/sites-enabled/gitlab root # service nginx reload
That's it!Now you can open the domain/subdomain url and see for yourself. Special thanks to mmoll and newton on #gitlab@freenode irc for the help.
A lot more in depth documentation is available: