GitLab installation on Fedora 16 (with gitolite)
This is updated version of my tutorial for GitLab 2.1. Old version can be found here
Attention: this guide seriously outdated! It has been written for Gitlab v2.1 and current version is >= v7.1.1. Almost everything has changed since then.
GitLab is a wonderful piece of software made by these guys and I’d like to try and install it on Fedora 16 system, as it is most recent Fedora OS at the time I am writnig this. I will base my tutorial on on found here by Déja. Also on my way to successful install I’ve stumbled upon this description, so I might have gain some experience from it too.
GitLab is Ruby on Rails application and it takes some experience to get it all working because of many, many, many dependencies and packages it needs. It’s nothing like simple PHP on Apache installation. But it works and it’s worth it, I assure you :)
Let’s begin! (by the way: I perform all as root user — again: test environment)
small edit: For people who only want this to work and not necessarily wish to know how and why, I have prepared easy installation scripts in here
another EDIT: GitLab is under heavy development and now it’s stable version is 2.1. This means that my guide might be not entirely accurate. Please be cautious. I’ll update it soon.
- First of all: I am working on virtual machine with brand new and fresh Fedora 16 installed. Minimal installation, just to make sure nothing messes with GitLab. Consider this a test environment.
- Once you have your OS ready, update it with yum update and also install some packages you will need on the way:
yum install make openssh-clients gcc libxml2 libxml2-devel \ libxslt libxslt-devel python-devel
- Check what version of ruby is available via yum. GitLab needs at least version 1.9.2
yum info ruby
on mine it says that the only available version for me is 220.127.116.117 so I have to get it somewhere else.
- Using RVM to install Ruby.
EDIT: I have switched to ruby 1.9.3p0 — it works and starts a lot faster, you can use it instead of 1.9.2-p290 in this guide.
I will use RVM, which stands for Ruby Version Manager — brilliant tool, which you can use to install and manage your Ruby with ease. Let’s check it out, shall we? (you can install Ruby any way you want — I’ll just do this RVM way)
Notice use of –with-openssl switch — without that passenger will complain about Ruby OpenSSL support and won’t compile in next step.
sudo bash -s stable < <(curl -sk https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) source /etc/profile.d/rvm.sh rvm install ruby-1.9.2-p290 --with-openssl rvm use ruby-1.9.2-p290 --default
Done. Just like that we have operational Ruby 1.9.2-p290. No RPMs, no going back in time.. nice, huh? :)
- Good. Small (nice) surprise: our RPM installed ruby gems for us, so now we only have to get rails gem.
first, just to make sure everything is up to date, execute:
rvm all do gem update --system
now install rails with:
rvm all do gem install rails
- Now we will install apache2 as a webserver and Passenger for ruby apps deployment. I know that most GitLab tutorials use nginx but I really like apache ;)
yum install -y httpd
rvm all do gem install passenger
as I mentioned: I use apache, so I will need passenger module for it:
first some required packages:
yum install -y gcc-c++ curl-devel openssl-devel zlib-devel \ httpd-devel apr-devel apr-util-devel
an then use
in order to install it.it gives you 2 information on how to proceed with apache configuration:
- add following lines to /etc/httpd/conf/httpd.conf (at the very end):
LoadModule passenger_module /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/ext/apache2/mod_passenger.so PassengerRoot /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.11 PassengerRuby /usr/bin/ruby
- and then create file named default.conf (or gitlab.conf, or something other you like) in /etc/httpd/conf.d/ containing these lines (remember to change to fit your environment):
<VirtualHost *:80> ServerName www.yourhost.com DocumentRoot /somewhere/public <Directory /somewhere/public> AllowOverride all Options -MultiViews </Directory> </VirtualHost>
(don’t worry, we’ll come back to this one later)
- add following lines to /etc/httpd/conf/httpd.conf (at the very end):
- Now it is time for gitolite. I won’t use gitosis because it is not actively developed any more and I found that new GitLab works better with gitolite.install it with
yum install -y gitolite
now, wasn’t that quick? :)
- Now we will need to create new gitolite server configuration and in order to do that we have to generate SSH key-pair. But first things first.
To get us started we will create git user with
adduser -r -m --shell /bin/bash \ --comment 'git version control' git mkdir /home/git/.ssh chown git:git -R /home/git/.ssh
Now we have to create SSH keys pair for him:
ssh-keygen -q -o -N '' -t rsa -f /home/git/.ssh/id_rsa
To initialize Gitolite we need to first edit it’s default configuration file and change default permissions and then initialize it by using git user:
sed -i 's/0077/0007/g' /usr/share/gitolite/conf/example.gitolite.rc su - git -c "gl-setup -q /home/git/.ssh/id_rsa.pub"
as mentioned here
- Just to make sure that git user has all necessary access rights to his own home directory after we have added SSH keys for him:
chown git:git -R /home/git/
- OK, time for next requirements: python Pip, I will go with method from original post and NOT use yum for that.
curl http://python-distribute.org/distribute_setup.py | python
- Database. We need it. We have it already — it was installed on the way as a dependency. Just to make sure check if you have SQLite at list version 3.6 with:
yum info sqlite
I have 18.104.22.168. All we need is SQLite development package, get it with:
yum install -y sqlite-devel
And now the main event! GitLabHQ!
I like install web apps in /var/www so we will go there and git clone GitLab:
cd /var/www git clone git://github.com/gitlabhq/gitlabhq.git cd gitlabhq/
we need to use pip to install some python dependencies:
pip install pygments
and bundler gem so it can later on do most of the work for us:
rvm all do gem install bundler
you will need one more dependency for bundle install
yum install -y libicu-devel
finally (remember to be in GitLab directory):
(go get yourself a coffee or other treat — it takes a while)
- Redis installation. More about Redis here
yum install -y redis
and start it with:
service redis start
- Preparing config files.copy database and gitlab config files from example to working copies:
cp config/gitlab.yml.example config/gitlab.yml cp config/database.yml.example config/database.yml
- DB setup:
And now database setup and import:
RAILS_ENV=production rake db:setup RAILS_ENV=production rake db:seed_fu
TIP: if you get errors here, check if you don’t have 2 versions of rake installed (I had somehow): 0.8.7 and 0.9.2. If you do, remove older with:
gem uninstall rake
and choose appropriate version. If you still have problems try:
gem install rake
-> don’t know why, but if it installs again same version of rake, it works.
- Apache virtual host configuration should look something like this (I told you, we will get back to that):file: /etc/httpd/conf.d/gitlab.conf
<VirtualHost *:80> ServerName www.yourhost.com DocumentRoot /var/www/gitlabhq/public <Directory /var/www/gitlabhq/public> AllowOverride all Options -MultiViews </Directory> </VirtualHost>
- enable apache user, co you can su into this account:
usermod -s /bin/bash -d /var/www/ apache
prepare SSH key for him (actually use one created for git user)
mkdir /var/www/.ssh cp -f /home/git/.ssh/id_rsa /var/www/.ssh/ && chown apache:apache /var/www/.ssh/id_rsa && chmod 600 /var/www/.ssh/id_rsa
add localhost to apache user known_hosts with:
ssh-keyscan localhost >> /var/www/.ssh/known_hosts
also give him permissions to his own home directory with:
chown -R apache:apache /var/www/
- add apache user to git group with:
usermod -a -G git apache
- check if repositories directory has correct permissions, it should be 770. You can set it with
chmod 770 /home/git/repositories/
- double check your firewall (for example iptables) if it allows connections on port 80 to your server.
important: Apache won’t be able o start with SELinux set to “enforcing”. Please set it to permissive.
- start apache server with:
service httpd start
- Now it all should work. Fingers crossed.. go to http://www.yourhost.com
- Now you should be able to log in using these credentials:
and you’re in :)
It wasn’t so hard, wasn’t it? ;)
- I get error 500 when I enter particular project and try to get into it’s “Admin” section. Don’t know how to fix it yet.To fix it, check if repositories directory has correct permissions, it should be 770. You can set it with
chmod 770 /home/git/repositories
also set this:
chmod 770 /home/git
- If Passenger insists, that we don’t have or he can’t see grit library (gem actually, as far as I know) even though we have it.
https://github.com/gitlabhq/grit.git (at master) is not checked out. Please run ‘bundle install‘ (Bundler::GitError)
Only resolution to this problem I have found is to (as root) change /usr/local/rvm/gems/ruby-1.9.3-p0/gems ownership to apache user with:
chown apache:root -R /usr/local/rvm/gems/ruby-1.9.3-p0/gems
I know that is not great resolution but it worked for me. If you’ll happen to know better way — please let me know, so I can update this tutorial and my knowledge of course ;)
I found another solution (instead of changing permissions): after first
edit Gemfile and in lines containing “git:” remove everything after first comma, for example:
gem "grit", :git => "https://github.com/gitlabhq/grit.git"
and so on.
then do again
and now passenger shouldn’t complain any more.