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:[bash]yum install make openssh-clients gcc libxml2 libxml2-devel \ libxslt libxslt-devel python-devel[/bash]
- Check what version of ruby is available via yum. GitLab needs at least version 1.9.2[bash]yum info ruby[/bash]
on mine it says that the only available version for me is 220.127.116.117 so I have to get it somewhere else. 4. 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.
[bash] sudo bash -s stable < <(curl -sk https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
rvm install ruby-1.9.2-p290 –with-openssl
rvm use ruby-1.9.2-p290 –default [/bash]
Done. Just like that we have operational Ruby 1.9.2-p290. No RPMs, no going back in time.. nice, huh? :) 5. 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:[bash]rvm all do gem update –system[/bash]
now install rails with:
[bash]rvm all do gem install rails[/bash] 6. 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 ;) [bash]yum install -y httpd[/bash] [bash]rvm all do gem install passenger[/bash]
as I mentioned: I use apache, so I will need passenger module for it: first some required packages:
[bash]yum install -y gcc-c++ curl-devel openssl-devel zlib-devel \ httpd-devel apr-devel apr-util-devel[/bash]
an then use
in order to install it.it gives you 2 information on how to proceed with apache configuration:
1 * add following lines to /etc/httpd/conf/httpd.conf (at the very end):
[bash] LoadModule passengermodule /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/ext/apache2/modpassenger.so PassengerRoot /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.11 PassengerRuby /usr/bin/ruby [/bash] * 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): [bash]<VirtualHost *:80> ServerName www.yourhost.com DocumentRoot /somewhere/public <Directory /somewhere/public> AllowOverride all Options -MultiViews </Directory> </VirtualHost> [/bash]
(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[bash]yum install -y gitolite[/bash]
now, wasn’t that quick? :) 8. 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 [bash] adduser -r -m –shell /bin/bash \ –comment ‘git version control’ git mkdir /home/git/.ssh chown git:git -R /home/git/.ssh [/bash]
Now we have to create SSH keys pair for him:
[bash]ssh-keygen -q -o -N “ -t rsa -f /home/git/.ssh/id_rsa[/bash]
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:
[bash]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”[/bash]
as mentioned here 9. 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: [bash]chown git:git -R /home/git/[/bash] 10. OK, time for next requirements: python Pip, I will go with method from original post and NOT use yum for that. [bash] curl http://python-distribute.org/distribute_setup.py | python [/bash]
[bash] easy_install pip [/bash] 11. 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:[bash]yum info sqlite[/bash]
I have 18.104.22.168. All we need is SQLite development package, get it with:
[bash]yum install -y sqlite-devel[/bash] 12. > And now the main event! GitLabHQ! I like install web apps in /var/www so we will go there and git clone GitLab:
[bash] cd /var/www
git clone git://github.com/gitlabhq/gitlabhq.git
cd gitlabhq/ [/bash]
we need to use pip to install some python dependencies:
[bash]pip install pygments[/bash]
and bundler gem so it can later on do most of the work for us:
[bash]rvm all do gem install bundler[/bash]
you will need one more dependency for bundle install
[bash]yum install -y libicu-devel[/bash]
finally (remember to be in GitLab directory):
(go get yourself a coffee or other treat - it takes a while) 13. Redis installation. More about Redis here[bash]yum install -y redis[/bash]
and start it with: [bash] service redis start [/bash] 14. Preparing config files.copy database and gitlab config files from example to working copies:
[bash] cp config/gitlab.yml.example config/gitlab.yml cp config/database.yml.example config/database.yml[/bash] 15. DB setup: And now database setup and import:[bash] RAILSENV=production rake db:setup RAILSENV=production rake db:seed_fu [/bash]
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:
[bash]gem uninstall rake[/bash]
and choose appropriate version. If you still have problems try:
[bash]gem install rake[/bash]
-> don’t know why, but if it installs again same version of rake, it works. 16. 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 [bash] <VirtualHost *:80> ServerName www.yourhost.com DocumentRoot /var/www/gitlabhq/public <Directory /var/www/gitlabhq/public> AllowOverride all Options -MultiViews </Directory> </VirtualHost> [/bash] 17. enable apache user, co you can su into this account: [bash]usermod -s /bin/bash -d /var/www/ apache[/bash]
prepare SSH key for him (actually use one created for git user)
[bash] mkdir /var/www/.ssh
cp -f /home/git/.ssh/idrsa /var/www/.ssh/ && chown apache:apache /var/www/.ssh/idrsa && chmod 600 /var/www/.ssh/id_rsa [/bash]
add localhost to apache user known_hosts with:
[bash]ssh-keyscan localhost >> /var/www/.ssh/known_hosts[/bash]
also give him permissions to his own home directory with:
[bash]chown -R apache:apache /var/www/[/bash]
18. add apache user to git group with: [bash]usermod -a -G git apache[/bash] 19. check if repositories directory has correct permissions, it should be 770. You can set it with[bash]chmod 770 /home/git/repositories/[/bash] 20. double check your firewall (for example iptables) if it allows connections on port 80 to your server. 21. ##### important: Apache won’t be able o start with SELinux set to “enforcing”. Please set it to permissive.
- start apache server with:[bash]service httpd start[/bash]
- 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] > > pass: 5iveL!fe 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[bash]chmod 770 /home/git/repositories[/bash]
also set this: [bash]chmod 770 /home/git[/bash] 2. 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:
[bash]chown apache:root -R /usr/local/rvm/gems/ruby-1.9.3-p0/gems[/bash]
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:
[bash]gem “grit”, :git => “https://github.com/gitlabhq/grit.git”[/bash]
and so on.
then do again
and now passenger shouldn’t complain any more.