1
Gitorious.org
2
=========================
3
4
Contributing
5
-------------
6
Please see HACKING
7
8
9
License
10
-------------
11
Please see the LICENSE file
12
13
14
Further documentation
15
---------------------
16
Also see the files in the doc/ folder, they contain further detailed information
17
about setting up the application for specific linux distributions such as 
18
CenOS and Ubuntu/Debian
19
20
21
===========================================================================
22
23
Installation to a production environment -- a partial walkthrough.
24
25
===========================================================================
26
27
=== Make ready
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
=== Dependencies
45
46
First, install each of these Libraries/applications:
47
48
* Git                   (http://git-scm.org)
49
* Oniguruma C library   (http://www.geocities.jp/kosako3/oniguruma/)
50
* Sphinx                (http://sphinxsearch.com/)
51
* MySQL                 (or whatever)
52
* ImageMagick           (need version >= 6.3.0)
53
* libyadis-ruby
54
* aspell (optional)
55
56
Next, get the gitorious code itself:
57
58
  # mkdir /www/gitorious
59
  # cd    /www/gitorious
60
  # git clone git://gitorious.org/gitorious/repositories/mainline.git gitorious
61
62
Install each of these Ruby libraries/bindings/gems:
63
64
* mysql
65
* RedCloth      (http://redcloth.org/)
66
* mime-types    (http://rubyforge.org/projects/mime-types)
67
* oniguruma     (http://rubyforge.org/projects/oniguruma)
68
* textpow       (http://rubyforge.org/projects/textpow)
69
* chronic       (http://rubyforge.org/projects/chronic)
70
* rmagick       (http://rubyforge.org/projects/rmagick)
71
* geoip
72
* ultrasphinx
73
* rmagick       (in ubuntu I had to sudo apt-get install librmagick-ruby librmagick-ruby-doc)
74
* ruby-openid   
75
* ruby-iconv
76
77
  # gem install mysql RedCloth mime-types oniguruma textpow \
78
      chronic rmagick geoip ultrasphinx ruby-openid 
79
80
=== Database
81
82
First we need a database.  Use the mysql command line app, or phpMyAdmin, or
83
whatever to create first a user.  Referring to
84
http://www-css.fnal.gov/dsg/external/freeware/mysqlAdmin.html:
85
86
  # mysql -p  -u root -h localhost
87
  CREATE USER 'git'@'localhost' IDENTIFIED BY 'awesome_password';
88
  GRANT ALL PRIVILEGES ON `git\_%` . * TO 'git'@'localhost';
89
  FLUSH PRIVILEGES;
90
  CREATE DATABASE `git_dev`  DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
91
  CREATE DATABASE `git_test` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
92
  CREATE DATABASE `git_prod` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
93
94
If you haven't set a password for the root user, now's a good time for that, too.
95
96
---
97
98
Edit database.yml to reflect your local database connection.  This is a standard
99
Ruby on Rails config file, not specific to gitorious -- if you have questions
100
here they're answered on the web, or consult the rails IRC channel.  (One hint:
101
NO TABS AT ALL in a .yml file.)  Our example:
102
103
development: 
104
  adapter:      mysql
105
  username:     git
106
  password:     awesome_password
107
  host:         localhost
108
  database:     git_dev
109
110
# The 'test' database will be erased and re-generated from your development
111
# database when you run 'rake'.  Must be different than the others!!
112
test:
113
  adapter:      mysql
114
  username:     git
115
  password:     awesome_password
116
  host:         localhost
117
  database:     git_test
118
119
production:
120
  adapter:      mysql
121
  username:     git
122
  password:     awesome_password
123
  host:         localhost
124
  database:     git_prod
125
126
---
127
128
Use rake to create the databases, migrate each, and run the tests:
129
130
rake db:create:all
131
for RAILS_ENV in development test production ; do
132
  rake db:migrate
133
done
134
rake test
135
136
FTW!
137
138
=== Gitorious config
139
  
140
* Copy the config/gitorious.sample.yml file to config/gitorious.yml
141
142
* Create a directory to hold project files
143
 
144
  # sudo mkdir  /gitorious/repositories
145
  
146
* Make a long, complicated string. You can run "apg -m 64", or if you lack 'apg'
147
    `dd if=/dev/random count=1 | md5sum` ,
148
  and put that on the 'cookie_secret' line (replacing the 'ssssht').
149
150
* Here's an example gitorious.yml (omitting comments) for local testing:
151
152
  cookie_secret: 26ee61bc4d6aa9870ab48d118a55e6ebcd11011dd6b61aa33536c024853c48d4e7c3d672aa57859
153
  repository_base_path:         "/gitorious/repositories"
154
  extra_html_head_data:
155
  system_message:
156
  gitorious_client_port:        3000
157
  gitorious_client_host:        localhost
158
  gitorious_host:               localhost       # gitorious.org
159
  gitorious_user:               gitslave
160
  
161
162
=== Get Sphinx going
163
for RAILS_ENV in development test production ; do
164
  RAILS_ENV=$RAILS_ENV rake ultrasphinx:configure
165
  RAILS_ENV=$RAILS_ENV rake ultrasphinx:index
166
done
167
RAILS_ENV=production rake ultrasphinx:daemon:start &
168
169
=== Tweak environment
170
171
* In environment.rb, uncomment config.action_controller.session -- choose a new
172
  session key string and generate your own secret key using something like
173
    (uptime; date) |sha1sum
174
175
* If you haven't set up your mailer, production mode will fail on login. Set
176
    config.action_mailer.delivery_method = :test
177
  for immediate gratification.
178
179
  
180
=== Run the server
181
182
From the gitorious directory,
183
184
# ./script/server
185
186
# RAILS_ENV=production ./script/server
187
188
It should start up on port 3000, listening only to local connections.  Ue "ssh
189
-L 3000:127.0.0.1:3000 -N you@yourbox.com" for testing.
190
191
You can now visit the site, sign up with your OpenID, put in your ssh key, and
192
poke around!  Once you get bored, make a test repository, wonder why nothing is
193
there yet, and then....
194
195
=== Hand-start the task_performer 
196
197
Key adoption, repo generation and other tasks are handled by the
198
'task_performer' script, which must be run periodically or on demand.
199
Run the script/task_performer and let it create the repository for you.
200
201
  # ./script/task_performer
202
203
   
204
4. Get your git on!
205
206
Push something to that repository (cd to a git repository with commits and do
207
"git push path/to/the/bare/repository/you/just/created master").  The actual
208
(bare) repos live in repository_base_path/#{project.slug}/#{repository.name}.git
209
Ex: the fubar project's mainline fork sits in a directory called
210
  
211
    /gitorious/repositories/fubar/mainline/fubar.git
212
213
This will be a 'bare' git repo -- you won't see files in it.
214
215
=== Button up
216
217
* In production, you'll want to have a limited-privileges user to run the git
218
  processes, just as you do for your webserver
219
220
* Make the tree invisible to any other non-root user; make the tree read-only by
221
  that user; but grant write access to the /tmp and /public/cache directories.
222
223
* Consider setting up the standard (lighttpd|nginx|apache) frontend <=> mongrel
224
  backend if you see traffic.
225
226
227
=== More Help
228
229
* Consult the mailinglist (http://groups.google.com/group/gitorious) or drop in
230
  by #gitorious on irc.freenode.net if you have questions.
231
232
=== Gotchas
233
234
Gitorious will add a 'forced command' to your ~/.ssh/authorized_keys file for
235
the target host: if you start finding ssh oddities suspect this first.  Don't
236
log out until you've ensured you can still log in remotely.