How to get Gitorious running on your own server

This is everything I’ve figured out so far about how to get Gitorious up and running on your own server. It’s not everything yet, but it’s a lot of stuff.

OK, so first you want to install the dependencies. I think this are all of them, assuming you’ve installed the basic rails stuff:

apt-get install librmagick-ruby libonig-dev
gem install mime-types oniguruma textpow chronic BlueCloth

Then make a place for Gitorious and download the code:

mkdir /path/for/gitorious; cd /path/for/gitorious
git clone git://  
cd mainline

It’s a good idea at this point to read the HACKING file for informational purposes.

The next thing we need to do is create a git user. This will be the user that gets used for SSH connections, running the task queue, and servering the repositories over HTTP:

adduser git

Once we’ve created a user, we can create a place for your git repositories. It has to be owned by the git user, and if you want people to be able to clone over HTTP, it has to be web-accessible. That means your web server has to be running as the git user:

mkdir /path/to/repos
chown git:git /path/to/repos

You are going to need to add your database settings and gitorious configuration. Start with:

cp config/gitorious.sample.yml config/gitorious.yml
nano config/gitorious.yml;

… and put in the necessary info. Next put in the database information:

cp config/database.sample.yml config/database.yml
nano config/database.yml

I called my databases gitorious_development, gitorious_production, and gitorious_test, and I set up a gitorious user in mysql with a fancy password. At this point you want to create the development databases, and then you can start the server:

rake db:migrate

You should now have the gitorious app running on http://localhost:3000 or wherever you specified in gitorious.yml. Give it a look in your web browser. If you want the server to run in the background, kill the current process (CTRL+C) and then run:

nohup script/server &

That will start the server up in a separate process and spit the output into nohup.out. You can try creating a user account through the web interface. If you don’t get an activation email, there’s something screwy with your mail server. I had to patch Gitorious to use a SMTP server, but that’s a separate post. As a workaround, just go into your gitorious_production database, find your account in the users table, and copy the date in the “created_at” column into the “activated_at” column.

Now you should be able to log in, create a project, and add your SSH public key to your profile. Unfortunately, Gitorious is going to tell you that your key and your project are being created, but they won’t get created without some more intervention.

In order to create the keys and the repositories, you have to set up a separate process that does those tasks regularly. Gitorious has a script set up for this purpose in script/task_performer. Go ahead and run that script, making sure that you run as the “git” user and that you set the correct rails environment. So if you are working in the development environment, run:

su git
RAILS_ENV=development script/task_performer

That will create the repositories and add the keys to /home/git/.ssh/authorized_keys. The authorized_keys file also specifies that before users can be authenticated for git push over SSH, the command “gitorious blah” needs to run (where blah is the users’s username). Except there is no gitorious command in the git user’s path. So let’s link it up:

ln -s RAILS_ROOT/script/gitorious /bin/gitorious

Now if you return to Gitorious, you should see that your keys and repositories have been created. You may want to stick that task_performer script in a cron job… or write a little script that will run it repeatedly in the background.

At this point, you should be able to do a git push (which goes over SSH) and a git clone over http, assuming your repositories are in a web accessible folder. In order to do git clones, you have to start the git daemon. Gitorious has a script for this, but again make sure to run as the git user:

su git
nohup script/git-daemon &

And now you should be able to do git:// clones too.

What’s left to do:

  • I haven’t configured ultrasphinx, so search doesn’t work.
  • I haven’t set up script/graph_generator, so there are no graphs.
  • I have no idea what script/fixup_hooks does. It might be important.

Thanks pygi and teknofire in #gitorious on for helpful pointers. Thanks Johan for guidance on getting ssh working correctly for git push.


Tags: ,

9 Responses to “How to get Gitorious running on your own server”

  1. Forkolator Blog » Blog Archive » Virtual domains, load balancing, suexec, and rails Says:

    […] documenting this process (and other things I’ve been learning about Ruby on Rails) over on  I’ve gotten most of Gitorious up and working, and now I’m moving on to try to figure […]

  2. AkitaOnRails Says:

    In the gitorius command it expects to have the environment variable SSH_ORIGINAL_COMMAND set, but what should be its value?

  3. AkitaOnRails Says:

    Hm, I get it know, actually when I do git push origin master from my “client”, it connected via SSH, runs “gitorious user” and the SSH_ORIGINAL_COMMAND comes from the git push local command.

    But for some reason the ssh key is not working as it keeps asking my password. Any clues about this?

  4. Steve Pomeroy Says:

    Instead of:

    “adduser git”

    You should probably be doing:

    “adduser –system git”

    so as to not have a password for the account.

  5. Erik Says:

    Ah, good tip. Thanks, Steve!

  6. Derek Says:

    Thanks Erik!

    This helped me get Gitorious installed on FreeBSD – it worked sweet with Passenger and Apache2.2! 😀

    But I now need to mess with email settings to register a user. I’ll probably just cheat via db to do this to begin with. =)

    QUESTION: Are you posting your patch or a tutorial on getting email configured for registration etc?


    On Related Topic – Gitorious and Redmine

    To anyone trying to install Gitorious and Redmine 0.7x on same box: – I found Redmine likes RedCloth version 3.0.4 – not 4+, whereas Gitorious wants 4.1.1+.

    I tried having both installed, but each install would complain of the other version being activated first, or at least one would – I forget.

    My noob solution was to set each up on a different hardware, which was end goal anyway.

    I imagine you – Erik, or other Rails guru may know how to fix this – so each Rails app looks for different version of gem – even when other gem is activated first?

    May help someone else.

    Thanks again!

  7. Mark Says:

    A VERY lenghty and complete post is here.

  8. game Design colleges In pennsylvania Says:

    This design is incredible! You certainly know how to keep a reader amused.
    Between your wit and your videos, I was almost moved to start my own
    blog (well, almost…HaHa!) Fantastic job. I really enjoyed what you had to say,
    and more than that, how you presented it. Too cool!

  9. inject terbaru Says:

    Thanks a lot for sharing this with all of us you actually know what you are speaking about!
    Bookmarked. Kindly also consult with my website =). We will have a link change agreement between us

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: