PageRenderTime 26ms CodeModel.GetById 34ms RepoModel.GetById 1ms app.codeStats 0ms

/defaults/help/Install.md

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