This is old version of my tutorial. Most recent version can be found here
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 writing this. I will base my tutorial on on found hereby 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 :)
(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
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 184.108.40.206 so I have to get it somewhere else.
I will do as it says here. I have tried it before and it works flawlessly. With one or two catches of course ;) Mentioned catches and tips:
you need wget, if you don’t have it already use
yum install -y wget
other needed packages (plus few dependencies) can be obtained by typing:
yum install -y readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel db4-devel byacc
if you are using virtual machine, like me, you can first make a snapshot of it, then build ruby RPM package, copy it to you host machine (or network share or whatever place outside virtual machine) and then go back in time to you snapshot. Voila! Clean system ready for further installing GitLab. All you need to do is install earlier created ruby RPM. Anyway this is what I’m gonna do today. Keep it clean.
last step - your RPM will end up somewhere in
~/rpmbuilds/RPMSdirectory. It will reside in folder named after your system architecture, in my case: i386
And here is how:
1 2 3 4 5 6 7 8
yum install -y rpm-build rpmdevtools rpmdev-setuptree cd ~/rpmbuild/SOURCES wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz cd ~/rpmbuild/SPECS curl https://raw.github.com/imeyer/ruby-1.9.2-rpm/master/ruby19.spec > ruby19.spec rpmbuild -bb ruby19.spec rpm -Uvh ~/rpmbuild/RPMS/x86_64/ruby-1.9.2p290-2.ruby-1.9.2p290-2.i386.rpm
I took my VM about 4 minutes to compile and prepare RPM. Not so bad.
Now I go back in time in my VM and install newly created RPM with
rpm -Uvh ruby-1.9.2p290-2.fc16.i386.rpm
Method #2. ( I prefer this one so far)
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?
1 2 3 4 5 6 7
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 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:
gem update --system
now install rails with:
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
gem install passenger
as I mentioned: I use apache, so I will need passenger module for it:
first some required packages:
yum install 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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 * add following lines to ```/etc/httpd/conf/httpd.conf``` (at the very end): ```bash 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 fancy) in ```/etc/httpd/conf.d/``` containing these lines (remember to change to fit your environment): ```bash <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)
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 su into gitolite user with
su - gitolite
now try to log into localhost via SSH -> it’s small thing which will make our life easier in the future.
Just make it add localhost to list of known host - no need to actually authenticate. SSH created for us ~/.ssh directory. That’s nice.SSH key generation is as easy as:
ssh-keygen -t rsa
use default path for saving key-pair (/var/lib/gitolite/.ssh/id_rsa) and no paraphrase. Test environment. Just a reminder.as for initialization of gitolite repository:
next hit ENTER and edit will open, change value of
REPO_UMASK to 0007
as mentioned hereLook like we are done here. Exit gitolite user shell and return to being almighty root himself ;)
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
220.127.116.11. All we need is SQLite development package, get it with:
yum install 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:
1 2 3 4 5
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:
gem install bundler
finally (remember to be in GitLab directory):
(go get yourself a coffee or other treat - it takes w while)
EDIT: For GitLab version 2.1 install Redis - without it rake will fail.:
yum install redis libicu-devel service redis start
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:
1 2 3 4 5 6 7 8
<VirtualHost *:80> ServerName www.yourhost.com DocumentRoot /var/www/gitlabhq/public <Directory /var/www/gitlabhq/public> AllowOverride all Options -MultiViews </Directory> </VirtualHost>
set correct settings in
in my case:# Git Hosting configuration
1 2 3 4 5 6 7
git_host: system: gitolite admin_uri: [email protected]:gitolite-admin base_path: /var/lib/gitolite/repositories/ host: localhost git_user: gitolite # port: 22
enable apache user, co you can su into this account:
usermod -s /bin/bash -d /var/www/ apache
also give him permissions to his own home directory with:
chown -R apache:apache /var/www/
(I know this kinda overrides last chown command…)
su - apache && ssh localhost(same thing as in step 8. with knowhosts file. ) exit apache’s shell and as root copy idrsa private key from /var/lib/gitolite/.ssh/ to /var/www/.ssh/ and make apache it’s owner with:
cp -f /var/lib/gitolite/.ssh/id_rsa /var/www/.ssh/ && chown apache:apache /var/www/.ssh/id_rsa && chmod 600 /var/www/.ssh/id_rsa
add apache user to gitolite group with:
usermod -a -G gitolite apache
check if repositories directory has correct permissions, it should be 770. You can set it with
chmod 770 /var/lib/gitolite/repositories/
double check your firewall (for example iptables) if it allows connections on port 80 to your server.
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:
user: [email protected]
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 /var/lib/gitolite/repositories/
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
I didn’t have gem grit installed, do:
gem install grit
also it won’t hurt to update all gems with:
Only resolution to this problem I have found is to run bundle again as a user who runs apache server: apache.Su into apache account with
su - apache
gem install grit
you’ll get error:
You don't have write permissions into the /usr/lib/ruby/gems/1.9.1 directory.
As root change it’s ownership to apache user with:
chown apache:root -R /usr/lib/ruby/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"
then do again
and now passenger shouldn’t complain any more.