Make Better Things

I like to make better things.

Install Gitlabhq with Gitolite on Mac OS X server (Mountain Lion 10.8)

Recently I got a task of setting up a mac mini server (Mountain Lion) with gitlabhq (with gitolite). I tried for around 15 times and finally got succeed. Here are the steps which I followed to setup, hope it will help someone setting up mac server with gitlab.
Step 1 – Create a user “git”

Step 2 – Login into user “git”

Step 3 - Install xcode 4.5

Step 4 - Install command line tools in Xcode. (Xcode -> Preferences -> downloads -> install command line tools)

Step 5 - Install “rails installer” from rails (this will install many dependencies)

Step 6 - Download and Install mysql from here

Step 7 – Setup root password for mysql with this command

/usr/local/mysql/bin/mysqladmin -u root password NEW_PASSWORD_HERE

Step 8 – Install Homebrew on mac (needed to install few things)

$ ruby -e "$(curl -fsSkL"

After homebrew install run doctor -

$ brew doctor

Step 9 – Get ownership of /usr/local

$ sudo chown -R $(whoami) /usr/local

Step 10 – Install qt and icu4c with brew.

$ brew install qt
$ brew install icu4c
$ brew install redis

Step 11 – Enable ssh login in system preferences. System Preferences -> Sharing -> Enable remote login

Step 12 – Create a ssh key without a password

$ ssh-keygen -t rsa -N ''

Step 13 -Clone gitolite

$ git clone git://

Step 14 - Install gitolite

$ gitolite/install
use the following full path for gitolite:

Step 15 - Put this in .bashrc file and save in your home folder (~) -

export GIT_EXEC_PATH=/opt/local/libexec/git-core

Step 16 - Add this in .bash_profile and save in home folder (~)

$ sudo nano .bash_profile

and put this below text.

export PATH=/Users/git/gitolite/src:$PATH
export PATH=/Users/git/bin:$PATH
export PATH=/usr/local/mysql/bin:$PATH

Restart terminal

Step 17 -Setting up gitolite

Create link for .pub file

$ ln -s .ssh/

setting up gitolite with ssh key

$ gitolite setup -pk ~/

Step 18 - Making sure you can connect with ssh

$ ssh localhost

Step 19 - Confirm that you can connect to the gitolite-admin repository

$ git clone git@localhost:gitolite-admin

Step 20 - Cloning gitlabhq

$ git clone -b stable git://

Step 21 - Running “bundle” on gitlabhq

$ cd gitlabhq
$ bundle

Step 22 - Bundle complete now -

$ bundle install --without development test

Step 23 - Configuriing gitlabhq

$ cp config/database.yml.example config/database.yml
$ cp config/gitlab.yml.example config/gitlab.yml

Step 24 - Now open this “config/gitlab.yml” and change “base_path” to “Users/git/repositories”

Step 25 - Open config/database.yml and change mysql password to your root account password. for production environment.

Step 26 - Setting up gitlabhq database in production environment -

 $ bundle exec rake db:setup RAILS_ENV=production

Got this error -

rake aborted!
dlopen(/usr/local/rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib
Referenced from: /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Reason: image not found – /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle

(See full trace by running task with –trace)

Got this fix on Stackoverflow -

$ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

Running previous command again -

$ bundle exec rake db:setup RAILS_ENV=production

 $ bundle exec rake db:setup RAILS_ENV=production

Step 27 - Run redis

$ redis-server /usr/local/etc/redis.conf

Step 28 - Run this -

$ bundle exec rake db:setup RAILS_ENV=production
$ bundle exec rake db:seed_fu RAILS_ENV=production

Step 29 - Run -

$ rails s -e production -p 8080

Step 30 - open “localhost:8080″ in browser and login with -


I hope you find this guide helpful. Comments are most welcome!

Category: git, mac


5 Responses

  1. Felix says:

    Great article!
    I have one question:
    Should the git user be administrator or a standard user?


    • Saurabh says:

      Standard user should work as per theory, but it didn’t work for me (not sure why) that’s why I ended up creating a admin account.

  2. andy says:

    thanks for the post! will start a configuration of my own today…
    could you think of any drawbacks using normal os x instead of server?

  3. Joe says:

    Hey -> great stuff – one problem though. I generated everything as you showed above – and even have it up in my browser. I create a user, add in his ssh-key (gen’d from the deskop) – create a project, and then when I go to add the first README file, I get the following:

    fatal: ‘jjupin/joe-five-two.git’ does not appear to be a git repository
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.

    Plus, I ran the following command: git clone
    and this one returns the same error message.

    Now, the git account works just fine for the gitolite-admin.git. But it fails whenever I create a new project under administrator and have it attempt to download.

    There’s something strange about permissions going on – have you seen this? Any ideas or clues to help?

    Thanks – Joe…

Leave a Reply