Shawn O. Pearce | e31d02c | 2009-12-08 12:21:37 -0800 | [diff] [blame] | 1 | Gerrit Code Review - Installation Guide |
| 2 | ======================================= |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 3 | |
Fredrik Luthander | 833aa74 | 2011-10-27 21:07:46 +0200 | [diff] [blame] | 4 | [[requirements]] |
| 5 | Requirements |
Martin Fick | 472bb9d | 2012-05-08 16:30:16 -0700 | [diff] [blame] | 6 | ------------ |
Fredrik Luthander | 833aa74 | 2011-10-27 21:07:46 +0200 | [diff] [blame] | 7 | To run the Gerrit service, the following requirements must be met on |
| 8 | the host: |
| 9 | |
| 10 | * JDK, minimum version 1.6 http://www.oracle.com/technetwork/java/javase/downloads/index.html[Download] |
| 11 | |
| 12 | You'll also need a SQL database to house the review metadata. You have the |
| 13 | choice of either using the embedded H2 or to host your own MySQL or PostgreSQL. |
| 14 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 15 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 16 | [[download]] |
| 17 | Download Gerrit |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 18 | --------------- |
| 19 | |
Shawn O. Pearce | 31af1ff | 2009-01-26 12:04:41 -0800 | [diff] [blame] | 20 | Current and past binary releases of Gerrit can be obtained from |
| 21 | the downloads page at the project site: |
| 22 | |
| 23 | * http://code.google.com/p/gerrit/downloads/list[Gerrit Downloads] |
| 24 | |
Shawn O. Pearce | 8ddb8cb | 2009-09-28 12:21:28 -0700 | [diff] [blame] | 25 | Download any current `*.war` package. The war will be referred to as |
| 26 | `gerrit.war` from this point forward, so you may find it easier to |
Anthony | d3aed4c | 2009-09-26 13:48:10 -0400 | [diff] [blame] | 27 | rename the downloaded file. |
Shawn O. Pearce | b8527ea | 2009-02-02 15:39:12 -0800 | [diff] [blame] | 28 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 29 | If you would prefer to build Gerrit directly from source, review |
| 30 | the notes under link:dev-readme.html[developer setup]. |
Shawn O. Pearce | 31af1ff | 2009-01-26 12:04:41 -0800 | [diff] [blame] | 31 | |
Fredrik Luthander | 833aa74 | 2011-10-27 21:07:46 +0200 | [diff] [blame] | 32 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 33 | [[createdb]] |
| 34 | Database Setup |
| 35 | -------------- |
Shawn O. Pearce | 31af1ff | 2009-01-26 12:04:41 -0800 | [diff] [blame] | 36 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 37 | [[createdb_h2]] |
| 38 | H2 |
| 39 | ~~ |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 40 | |
Fredrik Luthander | 833aa74 | 2011-10-27 21:07:46 +0200 | [diff] [blame] | 41 | During the init phase of Gerrit you will need to specify which database to use. |
| 42 | If you choose H2, Gerrit will automatically set up the embedded H2 database as |
| 43 | backend so no set up in advance is necessary. Also, no additional configuration is |
| 44 | necessary. Using the embedded H2 database is the easiest way to get a Gerrit |
| 45 | site up and running, making it ideal for proof of concepts or small team |
| 46 | servers. On the flip side, H2 is not the recommended option for large |
| 47 | corporate installations. This is because there is no easy way to interact |
| 48 | with the database while Gerrit is offline, it's not easy to backup the data, |
| 49 | and it's not possible to set up H2 in a load balanced/hotswap configuration. |
| 50 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 51 | |
Fredrik Luthander | a75dadc | 2011-10-28 06:58:18 +0200 | [diff] [blame] | 52 | If this option interests you, you might want to consider link:install-quick.html[the quick guide]. |
| 53 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 54 | [[createdb_postgres]] |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 55 | PostgreSQL |
| 56 | ~~~~~~~~~~ |
| 57 | |
Fredrik Luthander | 833aa74 | 2011-10-27 21:07:46 +0200 | [diff] [blame] | 58 | This option is more complicated than the H2 option but is recommended |
| 59 | for larger installations. It's the database backend with the largest userbase |
| 60 | in the Gerrit community. |
| 61 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 62 | Create a user for the web application within Postgres, assign it a |
| 63 | password, create a database to store the metadata, and grant the user |
| 64 | full rights on the newly created database: |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 65 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 66 | ---- |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 67 | createuser -A -D -P -E gerrit2 |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 68 | createdb -E UTF-8 -O gerrit2 reviewdb |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 69 | ---- |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 70 | |
Fredrik Luthander | 833aa74 | 2011-10-27 21:07:46 +0200 | [diff] [blame] | 71 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 72 | [[createdb_mysql]] |
Shawn O. Pearce | 86816ee | 2009-05-13 17:37:20 -0700 | [diff] [blame] | 73 | MySQL |
| 74 | ~~~~~ |
| 75 | |
Fredrik Luthander | 833aa74 | 2011-10-27 21:07:46 +0200 | [diff] [blame] | 76 | This option is also more complicated than the H2 option. Just as with |
| 77 | PostgreSQL it's also recommended for larger installations. |
| 78 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 79 | Create a user for the web application within the database, assign it a |
| 80 | password, create a database, and give the newly created user full |
| 81 | rights on it: |
Shawn O. Pearce | 86816ee | 2009-05-13 17:37:20 -0700 | [diff] [blame] | 82 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 83 | ---- |
| 84 | mysql |
| 85 | |
Shawn O. Pearce | 3e59563 | 2009-10-01 18:58:45 -0700 | [diff] [blame] | 86 | CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY 'secret'; |
Shawn O. Pearce | 86816ee | 2009-05-13 17:37:20 -0700 | [diff] [blame] | 87 | CREATE DATABASE reviewdb; |
Shawn O. Pearce | 4417424 | 2009-10-29 11:09:18 -0700 | [diff] [blame] | 88 | ALTER DATABASE reviewdb charset=latin1; |
Shawn O. Pearce | 86816ee | 2009-05-13 17:37:20 -0700 | [diff] [blame] | 89 | GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost'; |
Anthony | d3aed4c | 2009-09-26 13:48:10 -0400 | [diff] [blame] | 90 | FLUSH PRIVILEGES; |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 91 | ---- |
Shawn O. Pearce | 86816ee | 2009-05-13 17:37:20 -0700 | [diff] [blame] | 92 | |
Shawn O. Pearce | 0b91a63 | 2009-02-06 12:53:59 -0800 | [diff] [blame] | 93 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 94 | [[init]] |
| 95 | Initialize the Site |
| 96 | ------------------- |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 97 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 98 | Gerrit stores configuration files, the server's SSH keys, and the |
| 99 | managed Git repositories under a local directory, typically referred |
| 100 | to as `'$site_path'`. If the embedded H2 database is being used, |
| 101 | its data files will also be stored under this directory. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 102 | |
Fredrik Luthander | 833aa74 | 2011-10-27 21:07:46 +0200 | [diff] [blame] | 103 | You also have to decide where to store your server side git repositories. This |
| 104 | can either be a relative path under `'$site_path'` or an absolute path |
| 105 | anywhere on your server system. You have to choose a place before commencing |
| 106 | your init phase. |
| 107 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 108 | Initialize a new site directory by running the init command, passing |
| 109 | the path of the site directory to be created as an argument to the |
| 110 | '-d' option. Its recommended that Gerrit Code Review be given its |
| 111 | own user account on the host system: |
| 112 | |
| 113 | ---- |
| 114 | sudo adduser gerrit2 |
| 115 | sudo su gerrit2 |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 116 | |
Fredrik Luthander | 833aa74 | 2011-10-27 21:07:46 +0200 | [diff] [blame] | 117 | java -jar gerrit.war init -d /path/to/your/gerrit_application_directory |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 118 | ---- |
| 119 | |
Fredrik Luthander | 833aa74 | 2011-10-27 21:07:46 +0200 | [diff] [blame] | 120 | 'Please note:' If you choose a location where your new user doesn't |
| 121 | have any privileges, you may have to manually create the directory first and |
| 122 | then give ownership of that location to the `'gerrit2'` user. |
| 123 | |
| 124 | If run from an interactive terminal, the init command will prompt through a |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 125 | series of configuration questions, including gathering information |
Fredrik Luthander | 833aa74 | 2011-10-27 21:07:46 +0200 | [diff] [blame] | 126 | about the database created above. If the terminal is not interactive, |
| 127 | running the init command will choose some reasonable default selections, |
| 128 | and will use the embedded H2 database. Once the init phase is complete, |
| 129 | you can review your settings in the file `'$site_path/etc/gerrit.config'`. |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 130 | |
Fredrik Luthander | 833aa74 | 2011-10-27 21:07:46 +0200 | [diff] [blame] | 131 | When running the init command, additional JARs might be downloaded to |
| 132 | support optional selected functionality. If a download fails a URL will |
| 133 | be displayed and init will wait for the user to manually download the JAR |
| 134 | and store it in the target location. |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 135 | |
Fredrik Luthander | 833aa74 | 2011-10-27 21:07:46 +0200 | [diff] [blame] | 136 | When the init phase is complete, the daemon will be automatically started |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 137 | in the background and your web browser will open to the site: |
| 138 | |
| 139 | ---- |
| 140 | Initialized /home/gerrit2/review_site |
| 141 | Executing /home/gerrit2/review_site/bin/gerrit.sh start |
| 142 | Starting Gerrit Code Review: OK |
| 143 | Waiting for server to start ... OK |
| 144 | Opening browser ... |
| 145 | ---- |
| 146 | |
| 147 | When the browser opens, sign in to Gerrit through the web interface. |
| 148 | The first user to sign-in and register an account will be |
| 149 | automatically placed into the fully privileged Administrators group, |
| 150 | permitting server management over the web and over SSH. Subsequent |
| 151 | users will be automatically registered as unprivileged users. |
| 152 | |
| 153 | |
Fredrik Luthander | 833aa74 | 2011-10-27 21:07:46 +0200 | [diff] [blame] | 154 | Installation Complete |
| 155 | --------------------- |
| 156 | |
| 157 | Your base Gerrit server is now installed and running. You're now ready to |
| 158 | either set up more projects or start working with the projects you've already |
| 159 | imported. |
| 160 | |
| 161 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 162 | [[project_setup]] |
| 163 | Project Setup |
| 164 | ------------- |
| 165 | |
| 166 | See link:project-setup.html[Project Setup] for further details on |
| 167 | how to register a new project with Gerrit. This step is necessary |
| 168 | if existing Git repositories were not imported during 'init'. |
| 169 | |
| 170 | |
Karsten Dambekalns | a7f72a2 | 2011-03-25 14:21:59 +0100 | [diff] [blame] | 171 | [[rc_d]] |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 172 | Start/Stop Daemon |
| 173 | ----------------- |
| 174 | |
| 175 | To control the Gerrit Code Review daemon that is running in the |
| 176 | background, use the rc.d style start script created by 'init': |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 177 | |
| 178 | ==== |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 179 | review_site/bin/gerrit.sh start |
| 180 | review_site/bin/gerrit.sh stop |
| 181 | review_site/bin/gerrit.sh restart |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 182 | ==== |
| 183 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 184 | ('Optional') Link the gerrit.sh script into rc3.d so the daemon |
| 185 | automatically starts and stops with the operating system: |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 186 | |
| 187 | ==== |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 188 | sudo ln -snf `pwd`/review_site/bin/gerrit.sh /etc/init.d/gerrit.sh |
| 189 | sudo ln -snf ../init.d/gerrit.sh /etc/rc3.d/S90gerrit |
Shawn O. Pearce | 86816ee | 2009-05-13 17:37:20 -0700 | [diff] [blame] | 190 | ==== |
| 191 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 192 | To install Gerrit into an existing servlet container instead of using |
| 193 | the embedded Jetty server, see |
| 194 | link:install-j2ee.html[J2EE installation]. |
Shawn O. Pearce | 86816ee | 2009-05-13 17:37:20 -0700 | [diff] [blame] | 195 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 196 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 197 | [[customize]] |
| 198 | Site Customization |
| 199 | ------------------ |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 200 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 201 | Gerrit Code Review supports some site-specific customization options. |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 202 | For more information, see the related topics in this manual: |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 203 | |
Francois Marier | d550b46 | 2011-04-13 14:30:20 +1200 | [diff] [blame] | 204 | * link:config-reverseproxy.html[Reverse Proxy] |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 205 | * link:config-sso.html[Single Sign-On Systems] |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 206 | * link:config-headerfooter.html[Site Header/Footer] |
| 207 | * link:config-gitweb.html[Gitweb Integration] |
Shawn O. Pearce | 7b40571 | 2009-05-08 18:27:53 -0700 | [diff] [blame] | 208 | * link:config-gerrit.html[Other System Settings] |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 209 | |
Shawn O. Pearce | 0b91a63 | 2009-02-06 12:53:59 -0800 | [diff] [blame] | 210 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 211 | [[anonymous_access]] |
| 212 | Anonymous Access |
| 213 | ---------------- |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 214 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 215 | Exporting the Git repository directory |
| 216 | (link:config-gerrit.html#gerrit.basePath[gerrit.basePath]) over the |
| 217 | anonymous, unencrypted git:// protocol is more efficient than |
| 218 | Gerrit's internal SSH daemon. See the `git-daemon` documentation |
| 219 | for details on how to configure this if anonymous access is desired. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 220 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 221 | * http://www.kernel.org/pub/software/scm/git/docs/git-daemon.html[man git-daemon] |
Shawn O. Pearce | b546c9b | 2009-02-24 13:12:39 -0800 | [diff] [blame] | 222 | |
| 223 | |
Martin Fick | 472bb9d | 2012-05-08 16:30:16 -0700 | [diff] [blame] | 224 | [[plugins]] |
| 225 | Plugins |
| 226 | ------- |
| 227 | |
| 228 | Place Gerrit plugins in the review_site/plugins directory to have them loaded on Gerrit startup. |
| 229 | |
| 230 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 231 | External Documentation Links |
| 232 | ---------------------------- |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 233 | |
Shawn O. Pearce | 9ad8ba5 | 2009-12-11 19:06:21 -0800 | [diff] [blame] | 234 | * http://www.postgresql.org/docs/[PostgreSQL Documentation] |
| 235 | * http://dev.mysql.com/doc/[MySQL Documentation] |
| 236 | * http://www.kernel.org/pub/software/scm/git/docs/git-daemon.html[git-daemon] |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 237 | |
Shawn O. Pearce | 5500e69 | 2009-05-28 15:55:01 -0700 | [diff] [blame] | 238 | |
| 239 | GERRIT |
| 240 | ------ |
| 241 | Part of link:index.html[Gerrit Code Review] |