Installing gitorious on Ubuntu 10.04 HOWTO

I like using Git for my projects and I tend to host them outside of the computer I work on. I was finding the current way I was managing projects a bit cubersome so I decided to install Gitorious which gives you a nice web interface to manage it all!

Here are some instructions on installing Gitorious on your own Ubuntu 10.04 LTS server. The instructions from gitorious were a little out of date/confusing so I thought I would show you what I did to get it working successfully. It is based upon instructions from both gitorious’ own instructions and some others they link to, plus some other digging/googling around [1][2] and [3].

Updated: Added some fixes/clarifications from the comments below! (If you spot any errors do please tell me!)

A few notes on this tutorial: Firstly – This tutorial is approaching it’s first birthday which means (as with all things like this) it is getting somewhat outdated. With that in mind – approach with trepidation. I would read up on the relevant documentation from the developers yourself and make up your mind how helpful / relevant to you this whole process is.

Secondly – I have now moved to indefero (see http://www.indefero.net/open-source/) this is a lot easier to install and manage – offers all of the functionality that I have needed – which more than makes up for the lack of prettiness that gitorious had…

This is all done as root unless otherwise specified (a root prompt is indicated with a # and a normal user prompt is indicated with a $).

    1. Install some packages using Apt:
      # apt-get update
      # apt-get install build-essential zlib1g-dev tcl-dev libexpat-dev libcurl4-openssl-dev postfix apache2 mysql-server mysql-client apg geoip-bin libgeoip1 libgeoip-dev sqlite3 libsqlite3-dev imagemagick libpcre3 libpcre3-dev zlib1g zlib1g-dev libyaml-dev libmysqlclient15-dev apache2-dev libonig-dev phpmyadmin libmagick++-dev zip unzip memcached git-core git-svn git-doc git-cvs irb sphinxsearch
    2. Setup ActiveMQ:
      # apt-get install uuid uuid-dev openjdk-6-jre
      # wget http://www.powertech.no/apache/dist/activemq/apache-activemq/5.2.0/apache-activemq-5.2.0-bin.tar.gz
      # tar xzvf apache-activemq-5.2.0-bin.tar.gz -C /usr/local/
      # echo "export ACTIVEMQ_HOME=/usr/local/apache-activemq-5.2.0" >> /etc/activemq.conf
      # echo "export JAVA_HOME=/usr/" >> /etc/activemq.conf
      # adduser --system --no-create-home activemq
      # chown -R activemq /usr/local/apache-activemq-5.2.0/data
    3. Now to turn off the default multicasting activemq does, or other brokers on the same network will receive your queue items. Edit the networkConnectors setting in /usr/local/apache-activemq-5.2.0/conf/activemq.xml to something like this:
      <networkConnectors>
      <!-- by default just auto discover the other brokers -->
      <!-- Example of a static configuration: -->
      <networkConnector name="localhost" uri="static://(tcp://127.0.0.1:61616)"/>
      </networkConnectors>
    4. Now setup the startup script for ActiveMQ
      # cd /tmp
      # wget http://launchpadlibrarian.net/15645459/activemq
      # mv activemq /etc/init.d/activemq
      # chmod +x /etc/init.d/activemq
      # update-rc.d activemq defaults
      # service activemq start
    5. Download Ruby Enterprise Edition and install:
      # dpkg -i ruby-enterprise_1.8.7-2010.02_amd64_ubuntu10.04.deb
    6. Now get the latest version of the RubyGems software (download into a temporary directory):
      # cd /tmp
      # wget <ruby gems>
      # tar xzvf rubygems-1.3.7.tgz
      # cd rubygems-1.3.7
      # ruby setup.rb
      # ln -s /usr/bin/gem1.8 /usr/bin/gem
    7. Now time to install the required gems:
      # gem install -b --no-ri --no-rdoc rmagick chronic geoip daemons hoe echoe ruby-yadis ruby-openid mime-types diff-lcs json rack ruby-hmac rake stompserver passenger rails ultrasphinx mysql
      # gem install -b --no-ri --no-rdoc -v 1.0.1 rack
      # gem install -b --no-ri --no-rdoc -v 1.3.1.1 rdiscount
      # gem install -b --no-ri --no-rdoc -v 1.1 stomp
    8. Setup links to the correct versions:

# ln -s /var/lib/gems/1.8/gems/rake-0.8.7/bin/rake /usr/bin/rake
# ln -s /var/lib/gems/1.8/gems/stompserver-0.9.9/bin/stompserver /usr/bin/stompserver

  1. Download the gitorious package:
    # git clone git://gitorious.org/gitorious/mainline.git /var/www/gitorious
  2. Copy the required init.d files:
    # cp /var/www/gitorious/doc/templates/ubuntu/git-daemon /etc/init.d/
    # cp /var/www/gitorious/doc/templates/ubuntu/git-ultrasphinx /etc/init.d/
  3. Change /etc/init.d/git-daemon to have the following line:
    GIT_DAEMON="/usr/bin/ruby /var/www/gitorious/script/git-daemon -d"
  4. Create the git-poller and stomp initialisation scripts from the gitorious tutorial
  5. Set the correct permissions and activate the initialisation files:
    # chmod 755 /etc/init.d/git-ultrasphinx /etc/init.d/git-daemon /etc/init.d/stomp /etc/init.d/git-poller
    # update-rc.d stomp defaults
    # update-rc.d git-daemon defaults
    # update-rc.d git-ultrasphinx defaults
    # update-rc.d git-poller defaults
  6. Run apache setup script and follow the instructions:
    # /usr/local/bin/passenger-install-apache2-module
  7. Create /etc/apache2/mods-available/passenger.load with the following contents:
    LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.14/ext/apache2/mod_passenger.so
    PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.14
    PassengerRuby /usr/local/bin/ruby
  8. Enable apache2 modules and default ssl site:
    # a2enmod passenger
    # a2enmod rewrite
    # a2enmod ssl
    # a2ensite default-ssl
  9. Restart apache:
    # service apache2 restart
  10. Add a ‘git’ user to MySQL with global create privileges. Also give it all privileges on gitorious_production.
  11. Create /etc/apache2/sites-available/gitorious and /etc/apache2/sites-available/gitorious-ssl using the listings on the gitorious tutorial (the SSL is required for login!)
  12. Enable and disable the appropriate sites as follows:
    # a2dissite default
    # a2dissite default-ssl
    # a2ensite gitorious
    # a2ensite gitorious-ssl
  13. Add a user ‘git’ to the system:
    # adduser --system --home /var/www/gitorious/ --no-create-home --group --shell /bin/bash git
  14. Set permissions on the gitorious tree:
    # chown -R git:git /var/www/gitorious
  15. Now run the following sequence of commands:
    # su - git
    $ cd /var/www/gitorious
    $ mkdir .ssh
    $ touch .ssh/authorized_keys
    $ chmod 700 .ssh
    $ chmod 600 .ssh/authorized_keys
    $ mkdir tmp/pids
    $ mkdir repositories
    $ mkdir tarballs
    $ cp config/database.sample.yml config/database.yml
    $ cp config/gitorious.sample.yml config/gitorious.yml
    $ cp config/broker.yml.example config/broker.yml
  16. Edit config/database.yml: Remove every section but production
  17. Edit config/gitorious.yml: Remove every section but production (so at the top tab level only production: should exist)
  18. Set the gitorious.yml lines configurations like so (other entries not listed are to be left as defaults):
    cookie_secret: [set to output of apg -m 64]
    repository_base_path: "/var/www/gitorious/repositories"
    gitorious_client_port: 80
    gitorious_client_host: your.gitorious.domain.here
    gitorious_host: your.gitorious.domain.here
    archive_cache_dir: "/var/www/gitorious/tarballs"
    archive_work_dir: "/tmp/tarballs-work"
    hide_http_clone_urls: true
    is_gitorious_dot_org: false
  19. Run the following (note if you have to drop out to root again because it tells you that you missed some gems then remember to do the export again when you have su’d back into the git user!):
    $ export RAILS_ENV=production
    $ rake db:create
    $ rake db:migrate
    $ rake ultrasphinx:bootstrap
  20. Add the following line to the crontab:
    * * * * * cd /var/www/gitorious && /usr/bin/rake ultrasphinx:index RAILS_ENV=production
  21. Now create an admin user:
    $ env RAILS_ENV=production ruby script/create_admin
  22. Exit being the ‘git’ user and restart apache as root
    # service apache2 restart
  23. Now start the git-daemon service:
    # service git-daemon start
  24. Now you may find the login page not working, to fix this do the following (thanks to [2]):
    # gem uninstall i18n
    # gem install i18n -v=0.1
    # service apache2 restart
  25. Now create the adminstrator user:
    $ env RAILS_ENV=production ruby script/create_admin
This entry was posted in Howto, Server Admin and tagged , , . Bookmark the permalink.

37 Responses to Installing gitorious on Ubuntu 10.04 HOWTO

  1. Jason M. says:

    Hi ya. Good guide and halfway there. However, I think there may be a mistake in step (8). If I am wrong, sorry and ignore me. Otherwise, hope it helps others. 🙂

    # ln -s /var/lib/gems/1.8/gems/rake-0.8.7/bin/rake /usr/bin/rake
    # ln -s /var/lib/gems/1.8/gems/stompserver-0.9.9/bin/stompserver /usr/bin/stompserver

    • silly-scientist says:

      It is probably clearer to do as you have described (and will cause less problems), though my version will still work. I have updated step 8 to avoid any confusion. Thanks!

  2. Jason M. says:

    BTW, I have successfully setup the server although I have problems logging into the server due to user’s email login, which I don’t think I have setup properly yet but it is another issue that I can look at another day. If you have any advice, shoot 🙂 Basically, I cannot seem to match a username/email to login. I get the bright orange login page.

    Anyway, some items that I find different on my machine.

    (8).
    $ ln -s /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake /usr/bin/rake
    $ ln -s /usr/local/lib/ruby/gems/1.8/gems/stompserver-0.9.9/bin/stompserver /usr/bin/stomp

    (19). Note the ssl.
    Setup /etc/apache2/sites-available/gitorious and /etc/apache2/sites-available/gitorious-ssl

    (27). If you have errors in rake db:migrate, make sure you are in your gitorious folder and that you run the command in the folder with a Rakefile.

    A complementary page to the above if anyone has problems is to also refer to http://cjohansen.no/en/ruby/setting_up_gitorious_on_your_own_server. I managed to sort myself out using these two pages.

    Bravo! 🙂

    • silly-scientist says:

      Thanks for providing clarifications (I have fixed them in the instructions!). As for your login problem I have added a final step (point 33):

      env RAILS_ENV=production ruby script/create_admin

      This creates the adminstrator user which will then allow you to login to the site and manage things. The is particularly important when running in private mode as you won’t be able to register! Hope that fixes your issue!

  3. Jason M. says:

    No problem silly-scientist for the clarifications 🙂

    I did run the final step, $ env RAILS_ENV=production ruby script/create_admin but I cannot remember seeing any login and password details. I have to retry that again. Assuming I have done it and still cannot figure out what to do to login as administrator, is there anything else that I can do, e.g. reset password? My ears are all yours if you have any ideas.

    Thanks!

    • silly-scientist says:

      It should ask you for user details such as an email address, password etc. This has to be a valid email as it will send you an activation email to enable the account (and so your server needs to have a valid way to send email). The other option is you might be able to tweak the database entries (they should show if an admin user exists at least) – this will probably be very messy though.

  4. Artem says:

    Thanks, man. I’ve already tried official docs and article you mentioned in the begining, but with no luck. I’ve even asked guys from bitnami to add gitorious to their future stack list 🙂 Gonna make another one try with help of your great article.

  5. When you say to put on /etc/init.d/git-daemon following line:

    GIT_DAEMON=”/usr/bin/ruby /var/www/gitorious/script/git-daemon -d”

    Should be:

    GIT_DAEMON=”/usr/bin/env ruby /var/www/gitorious/script/git-daemon -d”

    Otherwise when run service git-daemon restart I get:

    Stopping git-daemon: Stopping git-daemon
    Starting git-daemon: /var/www/gitorious/script/git-daemon:3:in `require’: no such file to load — rubygems (LoadError)
    from /var/www/gitorious/script/git-daemon:3
    failure

  6. jpstrikesback says:

    it should be noted:

    – don’t install a RubyGems past 1.4.2
    – when running rake db:create make sure to add RAILS_ENV=production
    – git-daemon should be as the comment above indicates
    – you need to create a symbolic link to the gitorious script:

    ln -s $GITORIOUS_ROOT/script/gitorious /usr/local/bin/

    where $GITORIOUS_ROOT is the folder your Gitorious source code resides

    – remember to modify /etc/hosts

    Thanks for posting this guide!

  7. msdark says:

    I follow this guide, the gitorious wiki and this: http://cjohansen.no/en/ruby/setting_up_gitorious_on_your_own_server

    And i can’t login to my gitorious.. i can see the iindex page and some other static pages but when i click login i get this in chrome Error 118 (net::ERR_CONNECTION_TIMED_OUT): Se ha agotado el tiempo de la operación.

    I try with and without SSL but nothing happens.. any idea?

  8. Garth says:

    Hi,

    Great tut! Seem to be having an error when I run “rake db:create” it generates the following error:

    (in /var/www/gitorious)
    NOTE: Gem::SourceIndex#all_gems is deprecated with no replacement. It will be removed on or after 2011-10-01.
    Gem::SourceIndex#all_gems called from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/rubygems_integration.rb:256
    .
    rake aborted!
    Bundler couldn’t find some gems. Did you run `bundle install`?
    /var/www/gitorious/Rakefile:4

    Please help 🙂

  9. Hi there, how about adding a hint to ruby gems bundle install?

  10. Hugo says:

    hoe require RubyGems version >= 1.4

  11. Hugo says:

    Hello , I like the article…. and I’m facing a problem …
    http://groups.google.com/group/gitorious/browse_thread/thread/2cad3b7553cb3ced?fwc=1&pli=1

    root@i-0000008f:~# service git-daemon start
    Starting git-daemon: /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/runtime.rb:31:in `setup’: You have already activated daemons 1.1.3, but your Gemfile requires daemons 1.1.0. Consider using bundle exec. (Gem::LoadError)
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/spec_set.rb:12:in `each’

    You have already activated daemons 1.1.3, but your Gemfile requires daemons 1.1.0. Consider using bundle exec. (Gem::LoadError)

    but how to using bundle exec ? under /var/www/gitorious folder ? just type
    #bundle exec ? but it seems got another error message

  12. Hugo says:

    Hi Garth ,
    you can execute
    #bundle install
    before create DB
    under /var/www/gitorious folder

  13. Taris says:

    @Hugo:

    I had the same “daemons” error as you. Your “daemons”-version is too new and you have to downgrade:

    gem uninstall daemons
    gem install daemons –version 1.1.0

    In case gem asks ..uninstall ALL versions before installing daemons again
    After that i had another error with geoip and solved it with:

    gem uninstall geoip
    gem install geoip –version 0.8.9

    After that i was able to start the daemon

  14. TommyBlue says:

    I had a big problem with “rake ultrasphinx:bootstrap” because it created into “config/ultrasphinx/production.conf” a wrong query. I substituded into that file `base_tags` with `tags` and then:

    rake ultrasphinx:daemon:start RAILS_ENV=production
    rake ultrasphinx:index RAILS_ENV=production

    While using “rake ultrasphinx:bootstrap” it newly creates the wrong file so that command can’t be used

  15. Pingback: Installazione di Gitorious su Ubuntu server 10.04 | TommyBlue.it

  16. wielinde says:

    @TommyBlue Thanks for that advice. I ran into the same problem.

  17. karren says:

    I’ve encountered the same problem. But what I did was:

    On app/models/project.rb, change

    s.collect(:name, :from => “ActsAsTaggableOn::Tag”, :as => “category

    to

    s.collect(‘tags.name’, :as => “category”,

    That fixed the problem.

  18. Du Bois Eloi says:

    Hi all !

    I have successfully installed gitorious on my server but…
    I have this error when trying to log in:
    ssl_error_rx_record_too_long

    (I have been doing gem install i18n -v=0.1)

    Any idea ?
    Thanks !
    -Eloi du Bois

  19. Luciano says:

    Hello! Great Tutorial!!

    Got some issues on step 27 db:created that I was able to fix but now I am getting:

    $ bundle exec rake db:migrate
    rake aborted!
    will_paginate 3.0 is not compatible with Rails 2.3 or older

    Tasks: TOP => db:migrate => environment
    (See full trace by running task with –trace)

    Any ideas?
    thanks!

    • silly-scientist says:

      It looks like your rails installation is too old a version – have you tried upgrading it to a version > 2.4 as the error suggests?

  20. Luciano says:

    My rails is version 3. Could it be that also? I saw in one of the comments above: “don’t install a RubyGems past 1.4.2”. I installed 1.8..

    I will retry fro scratch and let you know.
    thanks

  21. ploker says:

    I followed the instructions and didn’t seem to have any problems, but when I go to gitorious in my web browser I just see the contents of the public folder as a file browser.

    Any ideas? Thanks.

  22. I would grab a book from our local library but I think I learned much more from this article.

  23. Joshua says:

    I was excited to try out gitorious, but this installation process is disturbing.

    I’m trying to keep the server as clean and light as possible. Are all those packages necessary? Isn’t anything that gitorious needs bundled with it?

    I also got stuck a few times on old, broken download links.

    I recommend the author give this article a makeover.

  24. The Silly Scientist says:

    @Joshua – thanks for the feedback. This article is approaching a year old now. Gitorious is (or at least was then) very cumbersome to install and far from the easy slick installation we have come to expect. I have since moved away from gitorious and found indefero much much easier to use/install and it has all the features I need – it just doesn’t have as much eye-candy, but that is more than made up for by the features / ease of use.

  25. Pingback: Kola Studios

  26. Eric Muyser says:

    Which version of echoe does gitorious use? Dang this dependency system sucks. As far as I can tell, any time a gem from the listed “gem install” is updated, it will easily screw up because the gem maintainer updates the rubygems dependency. Thus, we need specific versions for all of the dependencies (package.json in Node.js).

    “ERROR: Error installing echoe:
    echoe requires RubyGems version >= 1.8.4. Try ‘gem update –system’ to update RubyGems itself.”

  27. here says:

    Great post, you have pointed out some good points , I also think this s a very superb website.

  28. Pingback: Install gitorious on ubuntu 10.04 (braindump) « Software « laurii

  29. Pingback: 我期待!!! » Blog Archive » —Install gitorious

  30. Concepcion says:

    I believe what you published made a bunch of sense.
    However, think about this, suppose you were to create a killer headline?

    I ain’t suggesting your content isn’t solid., but what if you added a title that makes people want more?
    I mean Installing gitorious on Ubuntu 10.04 HOWTO

  31. Pingback: Gitorious Ubuntu Installation « tediscript.wordpress.com

  32. Pingback: Install gitorious on ubuntu 10.04 (braindump) @laurii

  33. Pingback: ruby on rails gitorious setup on ubuntu - Just just easy answers

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.