| 1 |
Gitorious.org |
| 2 |
============= |
| 3 |
|
| 4 |
Contributing |
| 5 |
============ |
| 6 |
|
| 7 |
Please see HACKING |
| 8 |
|
| 9 |
|
| 10 |
License |
| 11 |
======= |
| 12 |
|
| 13 |
Please see the LICENSE file |
| 14 |
|
| 15 |
|
| 16 |
Further documentation |
| 17 |
===================== |
| 18 |
Also see the files in the doc/ folder, they contain further detailed information |
| 19 |
about setting up the application for specific linux distributions such as |
| 20 |
CenOS and Ubuntu/Debian |
| 21 |
|
| 22 |
|
| 23 |
Installation to a production environment -- a partial walkthrough. |
| 24 |
================================================================== |
| 25 |
|
| 26 |
Make ready |
| 27 |
========== |
| 28 |
|
| 29 |
You may want to make separate directories, away from everything, to hold the |
| 30 |
site code and the git repository respectively. In production, you'll be setting |
| 31 |
up a special user account too, but don't worry about that yet. |
| 32 |
|
| 33 |
For this intro we're going to use, as examples, |
| 34 |
|
| 35 |
* /www/gitorious -- directory for the website code |
| 36 |
* /gitorious/repositories -- root directory for the git repositories |
| 37 |
* a MySQL database on localhost at port 3306 with a _mysql_ user 'gitorious' |
| 38 |
* eventually, a system account named 'gitslave' |
| 39 |
|
| 40 |
All of these can be adjusted to suit: specifically, dirs within your home |
| 41 |
directory are fine, and (though MySQL has the best development coverage), the |
| 42 |
website code should be free of mysql-isms/quirks. |
| 43 |
|
| 44 |
Prerequisites |
| 45 |
============= |
| 46 |
|
| 47 |
First of all, **we assume you have a working Ruby on Rails installation on |
| 48 |
your machine**. The Rails project has several resources about getting up and |
| 49 |
running with Rails, have a look at [getting started on |
| 50 |
rubyonrails.org](http://rubyonrails.org/download). Please ensure you're able |
| 51 |
to create a Rails project that uses your database of choice; this guide |
| 52 |
assumes your machine is ready to run Rails. |
| 53 |
|
| 54 |
Gitorious itself runs on either Ruby 1.8 or 1.9. Gitorious.org itself uses |
| 55 |
Ruby 1.9 and we recommend you do the same. |
| 56 |
|
| 57 |
|
| 58 |
Dependencies |
| 59 |
============ |
| 60 |
|
| 61 |
First, install each of these Libraries/applications: |
| 62 |
|
| 63 |
* Git (http://git-scm.org) |
| 64 |
* Sphinx (http://sphinxsearch.com/) |
| 65 |
* MySQL (or whatever) |
| 66 |
* ImageMagick (need version >= 6.3.0) |
| 67 |
* aspell (optional) |
| 68 |
|
| 69 |
An ActiveMessaging (http://code.google.com/p/activemessaging/wiki/Installation) compatible queue |
| 70 |
server. Gitorious.org runs ActiveMQ and STOMP, stompserver might be a nice |
| 71 |
flyweight alternative for your needs |
| 72 |
|
| 73 |
|
| 74 |
Getting the code |
| 75 |
================ |
| 76 |
|
| 77 |
Next, get the gitorious code itself: |
| 78 |
|
| 79 |
# mkdir /www/gitorious ;# or another location of your choice |
| 80 |
# cd /www/gitorious |
| 81 |
# git clone git://gitorious.org/gitorious/mainline.git gitorious |
| 82 |
|
| 83 |
Now you need edit a couple of configuration files. |
| 84 |
|
| 85 |
config/database.yml |
| 86 |
------------------ |
| 87 |
|
| 88 |
This file contains settings for the databases used for Gitorious. The |
| 89 |
Gitorious distribution provides a sample config file - database.sample.yml - |
| 90 |
that you could copy to config/database.yml. |
| 91 |
|
| 92 |
Gitorious should be database agnostic, so feel free to use your database of |
| 93 |
choice. Gitorious.org uses MySQL, but there shouldn't be any MySQL specific |
| 94 |
code in Gitorious, so use whatever you're most comfortable with. |
| 95 |
|
| 96 |
config/gitorious.yml |
| 97 |
-------------------- |
| 98 |
|
| 99 |
This file holds Gitorious specific configuration for each Rails environment. |
| 100 |
There's a sample file in config/gitorious.sample.yml that describes what each |
| 101 |
instruction means. Do make sure you have a section for each Rails environment, |
| 102 |
especially if you're upgrading an existing Gitorious installation. |
| 103 |
|
| 104 |
* Create a directory to hold project files |
| 105 |
|
| 106 |
# sudo mkdir /gitorious/repositories |
| 107 |
|
| 108 |
* Add the path to this directory under repository_base_path in gitorious.yml |
| 109 |
* Make a long, complicated string. You can run "apg -m 64", or if you lack 'apg' |
| 110 |
`dd if=/dev/random count=1 | md5sum` , |
| 111 |
and put that on the 'cookie_secret' line (replacing the 'ssssht'). |
| 112 |
|
| 113 |
|
| 114 |
config/broker.yml |
| 115 |
----------------- |
| 116 |
|
| 117 |
This file contains information about the Message Queing system used in your |
| 118 |
Gitorious installation. There's a section about this further down in this |
| 119 |
document, but as a starting point you can use the supplied sample file in |
| 120 |
config/broker.yml.example (cp config/broker.yml.example config/broker.yml) |
| 121 |
|
| 122 |
Install the gems required by Gitorious |
| 123 |
====================================== |
| 124 |
|
| 125 |
Next, you need to install a couple of gems: |
| 126 |
|
| 127 |
* chronic |
| 128 |
* daemons |
| 129 |
* diff-lcs |
| 130 |
* echoe |
| 131 |
* fastthread |
| 132 |
* geoip |
| 133 |
* highline |
| 134 |
* hoe |
| 135 |
* mime-types |
| 136 |
* oauth |
| 137 |
* rack >= 1.0.0 |
| 138 |
* rake |
| 139 |
* rdiscount >= 1.3.1.1 |
| 140 |
* RedCloth |
| 141 |
* rmagick |
| 142 |
* ruby-hmac |
| 143 |
* ruby-openid |
| 144 |
* ruby-yadis |
| 145 |
* stomp >= 1.1 |
| 146 |
|
| 147 |
Most of these can be installed using |
| 148 |
$ [sudo] rake gems:install |
| 149 |
|
| 150 |
|
| 151 |
Create your database |
| 152 |
==================== |
| 153 |
|
| 154 |
It is now time for creating the Gitorious database. |
| 155 |
|
| 156 |
rake db:create:all |
| 157 |
|
| 158 |
will create an empty database for you. |
| 159 |
|
| 160 |
|
| 161 |
Migrate your database |
| 162 |
===================== |
| 163 |
|
| 164 |
Now that you have a database, it's time to add the database schema |
| 165 |
|
| 166 |
rake db:migrate |
| 167 |
|
| 168 |
will take care of this for you |
| 169 |
|
| 170 |
|
| 171 |
Run the tests |
| 172 |
============= |
| 173 |
|
| 174 |
Running all the tests will ensure your Gitorious installation is correctly set |
| 175 |
up. It takes less than a minute to run all the tests, and gives confidence |
| 176 |
that the code is working as intended. |
| 177 |
|
| 178 |
There is at the time being one gem that's required to run the tests, so start |
| 179 |
out with |
| 180 |
|
| 181 |
[sudo] rake gems:install RAILS_ENV=test |
| 182 |
|
| 183 |
to make sure the test specific gems are installed. Then run the entire test |
| 184 |
suite: |
| 185 |
|
| 186 |
rake test |
| 187 |
|
| 188 |
Once all the tests pass, you're almost ready. |
| 189 |
|
| 190 |
Messaging server |
| 191 |
================ |
| 192 |
|
| 193 |
Gitorious uses the ActiveMessaging plugin, which supports a range of different |
| 194 |
messaging platforms, for sending demanding tasks for asynchronous processing. |
| 195 |
In order to these events to be processed, you need to run a messaging server |
| 196 |
when running Gitorious. |
| 197 |
|
| 198 |
A pretty reliable solution is to use Apache's ActiveMQ messaging queue system, |
| 199 |
located at http://activemq.apache.org/ . Download a version for you operating |
| 200 |
system, unpack, and follow the instructions to get running. On Unix-like |
| 201 |
systems, this is as easy as unpacking the tarball, going into it and running |
| 202 |
|
| 203 |
bin/activemq |
| 204 |
|
| 205 |
This will start the ActiveMQ server in a default setup, probably pretty well |
| 206 |
suited for development purposes. The ActiveMessaging plugin needs to know how |
| 207 |
to contact your MQ server, so it needs a config/broker.yml file. The Gitorious |
| 208 |
distribution provides an example (again, the defaults should work in a |
| 209 |
development environment). Just copy the config/broker.yml.example to |
| 210 |
config/broker.yml and start your server. |
| 211 |
|
| 212 |
The messages are sent to the server, in order to "consume" the messages, there |
| 213 |
is a script in scripts/poller that will run all registered "processors" (found |
| 214 |
in app/processors) that consume messages. In order to have eg. creation of |
| 215 |
repositories done automatically run |
| 216 |
|
| 217 |
script/poller start |
| 218 |
|
| 219 |
and the script will be started and daemonized. |
| 220 |
|
| 221 |
You're free to use other messaging protocols than the default Stomp protocol, |
| 222 |
which is required in config/environment.rb. The ActiveMessaging website |
| 223 |
(http://code.google.com/p/activemessaging/wiki/ActiveMessaging) has more |
| 224 |
information about how to set this up. |
| 225 |
|
| 226 |
|
| 227 |
Get Sphinx going |
| 228 |
================ |
| 229 |
|
| 230 |
$ env RAILS_ENV=production rake ultrasphinx:configure |
| 231 |
$ env RAILS_ENV=production rake ultrasphinx:index |
| 232 |
$ env RAILS_ENV=production rake ultrasphinx:daemon:start |
| 233 |
|
| 234 |
This sequence of commands will configure, index the database and start the |
| 235 |
sphinx daemon |
| 236 |
|
| 237 |
|
| 238 |
Tweak environment |
| 239 |
================= |
| 240 |
|
| 241 |
* If you haven't set up your mailer, production mode will fail on login. Set |
| 242 |
config.action_mailer.delivery_method = :test |
| 243 |
for immediate gratification. |
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
Start the server |
| 248 |
================ |
| 249 |
|
| 250 |
Now that you have all the components running, it's time to try Gitorious on |
| 251 |
your local machine: |
| 252 |
|
| 253 |
ruby script/server (for Mongrel/Webrick) |
| 254 |
thin start (for Thin) |
| 255 |
|
| 256 |
Remember the values you put for gitorious_host and gitorious_port in |
| 257 |
config/gitorious.yml? Go to http://<gitorious_host>:<gitorious_port> to see |
| 258 |
the main page of your local Gitorious. You are now officially up and running, |
| 259 |
congratulations! |
| 260 |
|
| 261 |
Production setup |
| 262 |
================ |
| 263 |
|
| 264 |
In a production environment, you'll want to automate as much as possible. We |
| 265 |
use Capistrano for deploying to gitorious.org, and use custom Capistrano |
| 266 |
recipes for starting and stopping the various tasks in Gitorious. |
| 267 |
|
| 268 |
The doc/recipies directory contains instructions for setting up init scripts |
| 269 |
for these tasks for various platforms. Please consult these, and feel free to |
| 270 |
contribute your own! |
| 271 |
|
| 272 |
Sphinx |
| 273 |
------ |
| 274 |
|
| 275 |
The sphinx deamon needs to be running in order for full text search to work. |
| 276 |
|
| 277 |
Git-deamon |
| 278 |
---------- |
| 279 |
|
| 280 |
For cloning over the Git protocol, Gitorious includes a custom git daemon |
| 281 |
found in script/git-daemon. |
| 282 |
|
| 283 |
script/poller |
| 284 |
------------- |
| 285 |
|
| 286 |
The script/poller script needs to be kept running. |
| 287 |
|
| 288 |
Web/application server |
| 289 |
---------------------- |
| 290 |
|
| 291 |
While Mongrel/thin is great for trying out Gitorious on a local install, in a |
| 292 |
production environment you'll probably want something a little more robust. |
| 293 |
Most Rails folks use Passenger with Apache or Nginx these days, Gitorious will |
| 294 |
play happily in such an environment. |
| 295 |
|
| 296 |
Support for pushing via SSH |
| 297 |
=========================== |
| 298 |
|
| 299 |
In order for people to be able to push to your repositories, you need an SSH |
| 300 |
daemon running. You'll also need a system user account that's used for git |
| 301 |
connections through SSH. Consult the recipies in doc/recipies for instructions |
| 302 |
on how to set this up. Until you've done this, the web frontend will work, but |
| 303 |
users won't be able to push their changes. |
| 304 |
|
| 305 |
Button up |
| 306 |
========= |
| 307 |
|
| 308 |
* In production, you'll want to have a limited-privileges user to run the git |
| 309 |
processes, just as you do for your webserver |
| 310 |
|
| 311 |
* Make the tree invisible to any other non-root user; make the tree read-only |
| 312 |
by that user; but grant write access to the /tmp and /public/cache |
| 313 |
directories. |
| 314 |
|
| 315 |
* Consider setting up the standard (lighttpd|nginx|apache) |
| 316 |
frontend <=> mongrel backend if you see traffic (or configure |
| 317 |
mod_passenger for apache2). |
| 318 |
|
| 319 |
|
| 320 |
More Help |
| 321 |
========= |
| 322 |
|
| 323 |
* Consult the mailinglist (http://groups.google.com/group/gitorious) or drop |
| 324 |
by #gitorious on irc.freenode.net if you have questions. |
| 325 |
|
| 326 |
Gotchas |
| 327 |
======= |
| 328 |
|
| 329 |
Gitorious will add a 'forced command' to your ~/.ssh/authorized_keys file for |
| 330 |
the target host: if you start finding ssh oddities suspect this first. Don't |
| 331 |
log out until you've ensured you can still log in remotely. |