final move of files
[web.mtrack] / help / Install
1 {{{
2 #!comment
3 This page is formatted using wiki markup.  You may find it easier to
4 run through the Quick Install steps and then navigate to help.php/Install
5 and continue reading.
6 }}}
7
8 = Installing mtrack =
9
10 == Pre-requisites ==
11
12  * A unix style operating system, such as Linux, Solaris, OS/X, FreeBSD etc.
13  * PHP 5.2, both the standalone CLI executable and Web Server (such as Apache) versions
14    * PHP must have PDO and pdo_sqlite support
15    * fileinfo or mime_magic support is recommended
16  * The {{{diff}}} and {{{diff3}}} command line tools
17  * Subversion command line tools ({{{svn}}} and {{{svnlook}}}) for Subversion repo support
18  * Mercurial command line tools ({{{hg}}}) for Mercurial repo support
19  * Access to the ''cron'' mechanism or equivalent on your system to schedule background tasks
20  * The {{{sendmail}}} command line tool for change notification emails
21
22 == Quick Install ==
23
24 It is recommended that you read this guide in full before installing, but if
25 you're impatient and want to see it running very quickly, you can follow these
26 steps.  They are intentionally terse; if you want more detail, read this guide
27 in full!
28
29 Note that if you want to import data from Trac, you will need to start over
30 with the initialization.
31
32 You should treat the quick install as a way to make a quick assessment about
33 mtrack before beginning your migration in earnest.
34
35 {{{
36 % cd $MTRACK
37 % php bin/init.php
38 }}}
39
40  * configure your webserver so that the $MTRACK/web dir is accessible
41  * turn off magic_quotes_gpc
42
43 You can now visit mtrack as an anonymous user and continue reading this
44 document by navigating to help.php/Install.
45
46 To do anything interesting, you will need to configure authentication.
47
48 == Background ==
49
50 An mtrack installation is defined in terms of the mtrack configuration file
51 {{{config.ini}}}, which contains system settings, and the application files,
52 which contain the program logic and that can be shared between between
53 instances so that multiple mtrack projects don't need to have their own copies
54 of the application files.
55
56 mtrack uses the environment variable {{{MTRACK_CONFIG_FILE}}} to locate the
57 {{{config.ini}}}, so sharing the same mtrack codebase across multiple projects
58 is just a matter of ensuring that the environment is correctly set for each
59 project.
60
61 == Installation ==
62
63 Decide where you would like the mtrack application files to reside on your
64 filesystem and put them there.  mtrack itself does not place any restrictions
65 on location, although the recommendation is that you do not place it in a path
66 where any of the parent directories have spaces in their names.
67
68 The {{{web}}} directory of the sources is intended to be the only portion
69 served via your web server, and it is recommended that you configure your
70 system such that the other directories are prevented from being served as a
71 security precaution.
72
73 You must also decide where you want to store the state for your mtrack project.
74 State includes the mtrack database (which holds tickets, wiki pages and more)
75 as well as attachment files and a Lucene search index.  All of these things are
76 encapsulated in a {{{var}}} directory.
77
78 The {{{var}}} directory ''must not'' be served via your web server.
79
80 == A note on Wiki ==
81
82 mtrack stores wiki pages in a repository.  By default, it will create this repo
83 in the {{{var}}} directory.  If you would like to locate the wiki repo
84 elsewhere, perhaps because you have want to export that and allow wiki edits to
85 be made via conventional editing tools and checked back in, then you may use
86 the {{{--repo}}} option to inform mtrack where it can find the existing wiki repository (you need to create it and ensure that it is accessible).
87
88
89 == Performing the Installation ==
90
91 From this point onwards, we use {{{$MTRACK}}} to denote the root of the mtrack
92 source files, and {{{$VARDIR}}} to denote the location that you selected to
93 hold the state for your mtrack project instance.  Each instance '''must''' have
94 its own distinct {{{$VARDIR}}}.
95
96 Each of the steps below cause {{{config.ini}}} to be created in the
97 {{{$MTRACK}}} directory; you may change this by usin the {{{--config-file}}}
98 option.
99
100 === Initializing ===
101
102 To initialize a fresh environment that is not related to any source
103 repositories:
104
105 {{{
106 % cd $MTRACK
107 % php bin/init.php --vardir $VARDIR
108 }}}
109
110 However, it is quite likely that you have a source repository or two; if so,
111 you will probably want to configure mtrack to see them.  You should also define
112 a ''project'' and associate it with the repo; this is used later for change
113 notifications.  You should initialize your instance using the following
114 invocation instead:
115
116 {{{
117 % cd $MTRACK
118 % php bin/init.php --vardir $VARDIR \
119    --repo $REPONAME svn /path/to/repo \
120    --link $PROJNAME $REPONAME /
121 }}}
122
123  * $REPONAME will show up as the top level name in the source browser
124  * $PROJNAME will show up in the subject line of notification email
125  * The {{{/}}} in the {{{--link}}} line causes all changes in $REPONAME to be recognized as happening within the $PROJNAME project.  More advanced rules are possible, such as allowing multiple projects to be contained with the same repo, but are not explained here.
126
127 If you are migrating from Trac, then you will want to associate your
128 repository and tell mtrack to import your Trac data:
129
130 {{{
131 % cd $MTRACK
132 % php bin/init.php --vardir $VARDIR \
133    --trac $PROJNAME /path/to/trac/environment/dir \
134    --repo $REPONAME svn /path/to/repo \
135    --link $PROJNAME $REPONAME /
136 }}}
137
138 If your Trac instance contains a lot of data, you might want to use the
139 {{{--disable-index}}} option to improve the import speed.  This turns off
140 incremental index updates during the import and trades import speed now for
141 indexing speed in the indexing background job that runs later.
142
143 {{{
144 #!comment
145
146 For Windows users - there is a setup.bat file in the /bin directory you may use
147 Right clik the setup.bat file and choose edit
148 Change the PHP_BIN location to the absolute path to your PHP directory.
149 Change the PROJ_NAM, REPO_NAME and REPO_PATH to the desired locations
150 and values.  You may also need to change REPO_TYPE if you are not setting up an
151 svn environment.
152 Save the changes, then exit and double click on setup.bat to initialize your environment
153
154 Currently the windows batch file does not support the --trac or --vardir arguments
155 If you are comfortable in a command line environment, you may open cmd.exe, cd
156 to the location of setup.bat, and pass the additional arguments you desire.
157 }}}
158
159 === Set the ownership on $VARDIR ===
160
161 Ensure that the web server process can access the mtrack state:
162
163 {{{
164 # chown -R nobody:nobody $VARDIR
165 }}}
166
167  * '''nobody''' must be changed to match the user account under which the web server process runs
168
169 {{{
170 #!comment
171  * In Windows environments, make sure the user your webserver is running as can write to $VARDIR
172    This is normally the SYSTEM user for apache2 installations and IUSR_computername for IIS installations
173    See php.net installation instructions for your version of IIS for more information
174 }}}
175
176 For a reference on the init script and its parameters, consult [help:bin/Init].
177
178 === Tool configuration ===
179
180 Once initialized, open {{{config.ini}}} in your text editor and fill out the
181 {{{[tools]}}} section so that mtrack knows the full path to the {{{svn}}},
182 {{{svnlook}}} and {{{php}}} command line utilities.  These will be guessed by
183 the initialization script based on what it can find your {{{$PATH}}}.
184
185 {{{
186 #!comment
187 Windows users can find the appropriate diff tools at
188 http://gnuwin32.sourceforge.net/packages/diffutils.htm Make sure to use
189 absolute paths to the appropriate tools and use quotes around the values.  Note
190 that if you have tortoisesvn installed you will not have the command line svn
191 tools required, you'll need to install the command lines tools as well.
192
193 For example, on a 64 bit system your paths will look similiar to this
194 {{{
195 hg = "C:\Program Files\TortoiseHg\hg.exe"
196 ; svn = /opt/msys/3rdParty/bin/svn
197 ; svnlook = /opt/msys/3rdParty/bin/svnlook
198 php = "C:\Program Files (x86)\PHP\php.exe"
199 diff3 = "C:\Program Files (x86)\diff\diff3.exe"
200 diff = "C:\Program Files (x86)\diff\dif.exe"
201 }}}
202 }}}
203
204 === Cron configuration ===
205
206 mtrack defers content indexing and email notifications so that they can be
207 intelligently handled in batches and not intrude on the web application
208 performance.
209
210 Configure a cron entry to run these batch processes every 10 minutes, using the following as a template:
211
212 {{{
213 0,10,20,30,40,50 * * * * nice su nobody -c "php $MTRACK/bin/update-search-index.php ; php $MTRACK/bin/send-notifications.php" >/dev/null 2>/dev/null
214 }}}
215
216  * '''nobody''' must be changed to match the user account under which the web server process runs
217
218 You are free to change the interval to anything you like (although the system
219 minimum is 1 minute); longer intervals allow more ticket changes to be
220 collapsed into an email at the expense of a larger perceived lag between the
221 time the event happens and the time the email is sent.
222
223 If you imported a large trac instance, the initial run of
224 {{{update-search-index.php}}} can take some time to run (and can tax the CPU
225 while it is running).  You need not worry about this; it is normal.  Both
226 {{{update-search-index.php}}} and {{{send-notifications.php}}} are intelligent
227 enough to only allow 1 instance to run concurrently, so even if there is a
228 backlog of work for them to process, they won't trip over each other or other
229 invocations launched from cron.
230
231 === Subversion commit-hook configuration ===
232
233 mtrack works best when integrated with your SCM.  There is a pre-commit hook
234 that can be used to enforce commit policies (such as proper formatting of
235 commit messages, or proper syntax in changed source files), and a post-commit
236 hook that can be used to apply commit messages as comments to related tickets.
237
238 Both the pre- and post-commit hooks are implemented by
239 {{{bin/svn-commit-hook}}}.  To enable it, arrange for your pre-commit hook to
240 invoke it:
241
242 If you do not have an existing hook, then create the following shell script in
243 the {{{hooks}}} directory of your subversion repository.  If you have an
244 existing hook, then adjust it to invoke the mtrack commit hook in addition to
245 the other actions it takes:
246
247 {{{
248 #!/bin/sh
249 php $MTRACK/bin/svn-commit-hook pre $1 $2 $MTRACK/config.ini
250 }}}
251
252 Then make sure it is executable:
253
254 {{{
255 # chmod a+rx hooks/pre-commit
256 }}}
257
258 The post-commit hook is similar:
259
260 {{{
261 #!/bin/sh
262 php $MTRACK/bin/svn-commit-hook post $1 $2 $MTRACK/config.ini
263 }}}
264
265 Then make sure it is executable:
266
267 {{{
268 # chmod a+rx hooks/post-commit
269 }}}
270
271 === Mercurial Commit Hook ===
272
273 Add this to the .hg/hgrc in the Mercurial repos:
274
275 {{{
276 [hooks]
277 changegroup.mtrack = php $MTRACK/bin/hg-commit-hook changegroup $MTRACK/config.ini
278 commit.mtrack = php $MTRACK/bin/hg-commit-hook commit $MTRACK/config.ini
279 pretxncommit.mtrack = php $MTRACK/bin/hg-commit-hook pretxncommit $MTRACK/config.ini
280 pretxnchangegroup.mtrack = php $MTRACK/bin/hg-commit-hook pretxnchangegroup $MTRACK/config.ini
281 }}}
282
283 === Notification Email Configuration ===
284
285 mtrack notifies users of changes based on the project associated with the
286 source code that was changed.  During initialization, we used the {{{--link}}}
287 argument to define a relationship between a location within a repo and a
288 project.
289
290 To enable email notification, we now need to associate an email address with a
291 project.  This is done via the Administration section; you can edit the email
292 address associated with the project from there.
293
294 Edit {{{config.ini}}} and set the '''weburl''' to match the URL you are going
295 to use for the web application.  It is important to include the trailing slash
296 in the URL that you put into the configuration file.  This value is used to
297 construct clickable links in notification emails.
298
299 === Authentication Considerations ===
300
301 mtrack uses plugins to control authentication and authorization.  By default,
302 it will respect the user identity of the command line user, but all web
303 accesses will be mapped to an ''anonymous'' user account that has read-only
304 access rights.
305
306 The recommended authentication approach is to configure your web server to
307 apply HTTP authentication to the mtrack application to secure it.
308
309 mtrack ships with an {{{MTrackAuth_HTTP}}} plugin that will recognize when the
310 web server has authenticated the user, and if not, will initiate Basic or
311 Digest authentication itself.
312
313 The default {{{config.ini}}} file leaves the HTTP auth module commented out;
314 you should uncomment it and inform it where it can find apache style group and
315 password files.  If the password file contains digest authentication
316 credentials, the filename must be prefixed with {{{digest:}}}.
317
318 {{{
319 [plugins]
320 MTrackAuth_HTTP = /path/to/htgroup, /path/to/htpasswd
321 ; for digest:
322 ;MTrackAuth_HTTP = /path/to/htgroup, digest:/path/to/htpasswd
323 }}}
324
325  * At this time, mtrack does not ship with a mechanism to allow both unauthenticated and authenticated access (but it could be implemented pretty easily)
326
327 More information on authentication can be found in [help:plugin/AuthHTTP].
328
329 == Web server Configuration ==
330
331  * Configure your web server such that your preferred URL maps to the {{{$MTRACK/web}}} directory
332  * Ensure that {{{magic_quotes_gpc}}} is set to {{{Off}}} in your PHP configuration.
333
334 A snippet from my httpd.conf:
335
336 {{{
337 # mtrack prototype
338 <Location /mtrack/eng>
339         AuthType Basic
340         AuthName "Access for mtrack"
341         AuthUserFile "/path/to/htpasswd"
342         AuthGroupFile "/path/to/htgroup"
343         require group developers
344 </Location>
345 <Directory /home/wez/mtrack/web>
346         Options Indexes FollowSymLinks
347         AllowOverride None
348         Order allow,deny
349         Allow from all
350
351         DirectoryIndex index.php
352         php_value magic_quotes_gpc Off
353 </Directory>
354 Alias /mtrack/eng /home/wez/mtrack/web
355 }}}
356
357 You may want to consider something like this for multi-instance hosting, if your "foo" project has its vardir at {{{/data/foo}}} and your "bar" project has its vardir at {{{/data/bar}}}:
358
359 {{{
360 Alias /mtrack/foo /home/wez/mtrack/web
361 SetEnvIf Request_URI "^/mtrack/foo(/|$)" "MTRACK_CONFIG_FILE=/data/foo/config.ini"
362 Alias /mtrack/bar /home/wez/mtrack/web
363 SetEnvIf Request_URI "^/mtrack/bar(/|$)" "MTRACK_CONFIG_FILE=/data/bar/config.ini"
364 }}}
365
366 == Done ==
367
368 Your basic configuration is now complete.  There are a number of other settings
369 in {{{config.ini}}} that can be adjusted (See [help:ConfigIni] for details),
370 but following the steps above should be sufficient to get you up and running.
371