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://gitorious.org/gitorious/mainline.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 script/server
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 irc.freenode.net for helpful pointers. Thanks Johan for guidance on getting ssh working correctly for git push.