Shawn O. Pearce | bad7561 | 2009-05-10 16:15:06 -0700 | [diff] [blame] | 1 | Gerrit2 - Installation Guide |
| 2 | ============================ |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 3 | |
Shawn O. Pearce | 31af1ff | 2009-01-26 12:04:41 -0800 | [diff] [blame] | 4 | You need a SQL database to house the Gerrit2 metadata. Currently |
Shawn O. Pearce | 86816ee | 2009-05-13 17:37:20 -0700 | [diff] [blame] | 5 | H2, MySQL and PostgreSQL are the only supported databases. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 6 | |
| 7 | Important Links |
| 8 | --------------- |
| 9 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 10 | PostgreSQL: |
| 11 | |
| 12 | * http://www.postgresql.org/docs/[Documentation] |
Shawn O. Pearce | 86816ee | 2009-05-13 17:37:20 -0700 | [diff] [blame] | 13 | * link:http://jdbc.postgresql.org/download.html[JDBC Driver] |
| 14 | |
| 15 | MySQL: |
| 16 | |
| 17 | * http://dev.mysql.com/doc/[Documentation] |
| 18 | * http://dev.mysql.com/downloads/connector/j/5.0.html[JDBC Driver] |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 19 | |
Shawn O. Pearce | 933fcd9 | 2009-02-06 14:38:11 -0800 | [diff] [blame] | 20 | Optional Libraries: |
| 21 | |
Shawn O. Pearce | 933fcd9 | 2009-02-06 14:38:11 -0800 | [diff] [blame] | 22 | * link:http://sourceforge.net/project/showfiles.php?group_id=25357[c3p0 JDBC Driver] |
| 23 | * link:http://www.bouncycastle.org/java.html[Bouncy Castle Crypto API] |
| 24 | * link:http://java.sun.com/products/javamail/downloads/index.html[JavaMail] |
| 25 | |
Shawn O. Pearce | 0b91a63 | 2009-02-06 12:53:59 -0800 | [diff] [blame] | 26 | |
Shawn O. Pearce | 31af1ff | 2009-01-26 12:04:41 -0800 | [diff] [blame] | 27 | Downloading Gerrit |
| 28 | ------------------ |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 29 | |
Shawn O. Pearce | 31af1ff | 2009-01-26 12:04:41 -0800 | [diff] [blame] | 30 | Current and past binary releases of Gerrit can be obtained from |
| 31 | the downloads page at the project site: |
| 32 | |
| 33 | * http://code.google.com/p/gerrit/downloads/list[Gerrit Downloads] |
| 34 | |
Shawn O. Pearce | b8527ea | 2009-02-02 15:39:12 -0800 | [diff] [blame] | 35 | Download any current `*.war` package. |
| 36 | |
Shawn O. Pearce | 31af1ff | 2009-01-26 12:04:41 -0800 | [diff] [blame] | 37 | |
| 38 | Building Gerrit From Source |
| 39 | --------------------------- |
| 40 | |
| 41 | Alternatively, you can build the application distribution using |
| 42 | Maven from a source download obtained directly from Git: |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 43 | |
| 44 | ==== |
Shawn O. Pearce | 1d394a5 | 2009-02-25 09:05:52 -0800 | [diff] [blame] | 45 | git clone git://android.git.kernel.org/tools/gerrit.git |
| 46 | cd gerrit |
Shawn O. Pearce | 8d2f184 | 2009-05-13 07:59:04 -0700 | [diff] [blame] | 47 | mvn clean package |
Shawn O. Pearce | 263786e | 2009-02-02 15:49:26 -0800 | [diff] [blame] | 48 | cp target/gerrit-*.war ...YOUR.DEST.../gerrit.war |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 49 | ==== |
| 50 | |
| 51 | The first build may take a while as dependencies are searched |
| 52 | for and downloaded from Maven distribution repositories. |
| 53 | |
Shawn O. Pearce | 31af1ff | 2009-01-26 12:04:41 -0800 | [diff] [blame] | 54 | Apache Maven: |
| 55 | |
| 56 | * http://maven.apache.org/download.html[Download] |
| 57 | * http://maven.apache.org/run-maven/index.html[Running Maven] |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 58 | |
Shawn O. Pearce | b951af1 | 2009-02-06 12:32:18 -0800 | [diff] [blame] | 59 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 60 | Setting up the Database |
| 61 | ----------------------- |
| 62 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 63 | PostgreSQL |
| 64 | ~~~~~~~~~~ |
| 65 | |
| 66 | Create a Gerrit specific user as a normal user (no superuser access) |
| 67 | and assign it an encrypted password: |
| 68 | |
| 69 | ==== |
| 70 | createuser -A -D -P -E gerrit2 |
| 71 | ==== |
| 72 | |
| 73 | Create the database to store the Gerrit metadata, and set the user |
| 74 | you just created as the owner of that database: |
| 75 | |
| 76 | ==== |
| 77 | createdb -E UTF-8 -O gerrit2 reviewdb |
| 78 | ==== |
| 79 | |
Shawn O. Pearce | 86816ee | 2009-05-13 17:37:20 -0700 | [diff] [blame] | 80 | MySQL |
| 81 | ~~~~~ |
| 82 | |
| 83 | Create a Gerrit specific user within the database and assign it a |
| 84 | password, create a database, and give the user full rights: |
| 85 | |
| 86 | ==== |
| 87 | CREATE USER gerrit2 IDENTIFIED BY PASSWORD 'secret'; |
| 88 | CREATE DATABASE reviewdb; |
| 89 | GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost'; |
| 90 | ==== |
| 91 | |
Shawn O. Pearce | 0b91a63 | 2009-02-06 12:53:59 -0800 | [diff] [blame] | 92 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 93 | Initialize the Schema |
| 94 | --------------------- |
| 95 | |
| 96 | Create the Gerrit 2 Tables |
| 97 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 98 | |
Shawn O. Pearce | b8527ea | 2009-02-02 15:39:12 -0800 | [diff] [blame] | 99 | Either run CreateSchema from the command line: |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 100 | |
| 101 | ==== |
Shawn O. Pearce | b8527ea | 2009-02-02 15:39:12 -0800 | [diff] [blame] | 102 | java -jar gerrit.war --cat extra/GerritServer.properties_example >GerritServer.properties |
| 103 | edit GerritServer.properties |
| 104 | |
| 105 | java -jar gerrit.war CreateSchema |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 106 | ==== |
| 107 | |
| 108 | Or, run the application once in a container to force it to initialize |
| 109 | the database schema before accessing it. (See below for deployment |
| 110 | setup documentation.) If you use this approach, it is recommended |
| 111 | that you stop the application before continuing with the setup. |
| 112 | |
| 113 | Add Indexes |
| 114 | ~~~~~~~~~~~ |
| 115 | |
| 116 | A script should be run to create the query indexes, so Gerrit |
| 117 | can avoid table scans when looking up information. Run the |
Shawn O. Pearce | 86816ee | 2009-05-13 17:37:20 -0700 | [diff] [blame] | 118 | index script through your database's query tool. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 119 | |
Shawn O. Pearce | 86816ee | 2009-05-13 17:37:20 -0700 | [diff] [blame] | 120 | PostgreSQL: |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 121 | |
| 122 | ==== |
Shawn O. Pearce | 86816ee | 2009-05-13 17:37:20 -0700 | [diff] [blame] | 123 | java -jar gerrit.war --cat sql/index_postgres.sql | psql reviewdb |
| 124 | ==== |
| 125 | |
| 126 | MySQL: |
| 127 | |
| 128 | ==== |
| 129 | java -jar gerrit.war --cat sql/index_generic.sql | mysql reviewdb |
| 130 | java -jar gerrit.war --cat sql/mysql_nextval.sql | mysql reviewdb |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 131 | ==== |
| 132 | |
| 133 | Configure site_path |
| 134 | ~~~~~~~~~~~~~~~~~~~ |
| 135 | |
| 136 | This directory holds server-specific configuration files and |
| 137 | assets used to customize the deployment. Gerrit needs read |
| 138 | access (but not write access) to the directory. The path |
| 139 | is stored in `system_config.site_path`, so you will need to |
| 140 | update the database with this value. |
| 141 | |
| 142 | ==== |
| 143 | mkdir /home/gerrit/cfg |
| 144 | cd /home/gerrit/cfg |
| 145 | |
Shawn O. Pearce | 86816ee | 2009-05-13 17:37:20 -0700 | [diff] [blame] | 146 | UPDATE system_config SET site_path='/home/gerrit/cfg' |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 147 | ==== |
| 148 | |
Shawn O. Pearce | af12e8e | 2009-02-06 13:49:43 -0800 | [diff] [blame] | 149 | SSH Host Keys |
| 150 | ~~~~~~~~~~~~~ |
| 151 | |
| 152 | If you choose to install the Bouncy Castle Crypto APIs (see below) |
| 153 | you must create RSA and DSA host keys for the daemon: |
| 154 | ==== |
| 155 | ssh-keygen -t rsa -P '' -f ssh_host_rsa_key |
| 156 | ssh-keygen -t dsa -P '' -f ssh_host_dsa_key |
| 157 | ==== |
| 158 | |
| 159 | These keys are used as the host keys for the internal SSH daemon |
| 160 | run by Gerrit. You may wish to backup these key files to ensure |
| 161 | they can be restored in the event of a disaster. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 162 | |
| 163 | The private key files (`ssh_host_rsa_key`, `ssh_host_dsa_key`) should |
| 164 | be readable *only* by the account that is executing Gerrit2's web |
| 165 | application container. It is a security risk to make these files |
| 166 | readable by anyone else. |
| 167 | |
Shawn O. Pearce | af12e8e | 2009-02-06 13:49:43 -0800 | [diff] [blame] | 168 | If you don't install Bouncy Castle, Gerrit will automatically |
| 169 | create a host key and save a copy to `'site_path'/ssh_host_key` |
| 170 | during first startup. For this to work correctly, Gerrit will |
| 171 | require write access to the directory. |
| 172 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 173 | Create Git Repository Base |
| 174 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 175 | |
| 176 | This directory holds the Git repositories that Gerrit knows about |
| 177 | and can service. Gerrit needs write access to this directory and |
| 178 | any Git repository stored within it. |
| 179 | |
| 180 | ==== |
| 181 | mkdir /srv/git |
Shawn O. Pearce | 86816ee | 2009-05-13 17:37:20 -0700 | [diff] [blame] | 182 | UPDATE system_config SET git_base_path='/srv/git' |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 183 | ==== |
| 184 | |
| 185 | You may wish to consider also exporting this directory over the |
| 186 | anonymous git:// protocol, as it is more efficient than Gerrit's |
| 187 | internal ssh daemon. See the `git-daemon` documentation for details |
| 188 | on how to configure this if anonymous access is desired. |
| 189 | |
| 190 | * http://www.kernel.org/pub/software/scm/git/docs/git-daemon.html[man git-daemon] |
| 191 | |
| 192 | Futher Configuration |
| 193 | ~~~~~~~~~~~~~~~~~~~~ |
| 194 | |
| 195 | Gerrit2 supports some site-specific customizations. These are |
| 196 | optional and are not required to run a server, but may be desired. |
| 197 | |
Shawn O. Pearce | f384b44 | 2009-01-10 16:20:56 -0800 | [diff] [blame] | 198 | * link:config-sso.html[Single Sign-On Systems] |
Shawn O. Pearce | 5a14d66 | 2009-01-23 16:39:51 -0800 | [diff] [blame] | 199 | * link:config-replication.html[Git Replication/Mirroring] |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 200 | * link:config-headerfooter.html[Site Header/Footer] |
| 201 | * link:config-gitweb.html[Gitweb Integration] |
Shawn O. Pearce | 7b40571 | 2009-05-08 18:27:53 -0700 | [diff] [blame] | 202 | * link:config-gerrit.html[Other System Settings] |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 203 | |
Shawn O. Pearce | 0b91a63 | 2009-02-06 12:53:59 -0800 | [diff] [blame] | 204 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 205 | Application Deployment |
| 206 | ----------------------- |
| 207 | |
| 208 | Jetty |
| 209 | ~~~~~ |
| 210 | |
Shawn O. Pearce | 0004f98 | 2009-02-20 18:44:51 -0800 | [diff] [blame] | 211 | [NOTE] |
| 212 | The instructions listed here were tested with Jetty 6.1.14 or later. |
| 213 | These are known to not work on much older versions, such as 6.1.3. |
| 214 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 215 | These directions will configure Gerrit as the default web |
| 216 | application, allowing URLs like `http://example.com/4543` to |
| 217 | jump directly to change 4543. |
| 218 | |
| 219 | Download and unzip a release version of Jetty. From here on we |
| 220 | call the unpacked directory `$JETTY_HOME`. |
| 221 | |
Shawn O. Pearce | af12e8e | 2009-02-06 13:49:43 -0800 | [diff] [blame] | 222 | * link:http://dist.codehaus.org/jetty/[Jetty Downloads] |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 223 | |
Shawn O. Pearce | 933fcd9 | 2009-02-06 14:38:11 -0800 | [diff] [blame] | 224 | Install the required JDBC drivers by copying them into the |
| 225 | `'$JETTY_HOME'/lib/plus` directory. Drivers can be obtained from |
| 226 | their source projects: |
Shawn O. Pearce | b8527ea | 2009-02-02 15:39:12 -0800 | [diff] [blame] | 227 | |
Shawn O. Pearce | 933fcd9 | 2009-02-06 14:38:11 -0800 | [diff] [blame] | 228 | * link:http://jdbc.postgresql.org/download.html[PostgreSQL JDBC Driver] |
| 229 | * link:http://sourceforge.net/project/showfiles.php?group_id=25357[c3p0 JDBC Driver] |
| 230 | |
| 231 | Consider installing Bouncy Castle Cypto APIs into the |
| 232 | `'$JETTY_HOME'/lib/plus` directory. Some of the Bouncy Castle |
Shawn O. Pearce | af12e8e | 2009-02-06 13:49:43 -0800 | [diff] [blame] | 233 | implementations are faster than then ones that come in the JRE, |
Shawn O. Pearce | 933fcd9 | 2009-02-06 14:38:11 -0800 | [diff] [blame] | 234 | and they may support additional encryption algorithms: |
Shawn O. Pearce | af12e8e | 2009-02-06 13:49:43 -0800 | [diff] [blame] | 235 | |
Shawn O. Pearce | 933fcd9 | 2009-02-06 14:38:11 -0800 | [diff] [blame] | 236 | * link:http://www.bouncycastle.org/java.html[Bouncy Castle Crypto API] |
Shawn O. Pearce | af12e8e | 2009-02-06 13:49:43 -0800 | [diff] [blame] | 237 | |
Shawn O. Pearce | ce0cb8b | 2009-05-08 16:22:59 -0700 | [diff] [blame] | 238 | Jetty comes with JavaMail, so there is no need to install it. |
| 239 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 240 | Copy Gerrit into the deployment: |
| 241 | ==== |
Shawn O. Pearce | b8527ea | 2009-02-02 15:39:12 -0800 | [diff] [blame] | 242 | java -jar gerrit.war --cat extra/jetty_gerrit.xml >$JETTY_HOME/contexts/gerrit.xml |
| 243 | cp gerrit.war $JETTY_HOME/webapps/gerrit.war |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 244 | |
| 245 | rm -f $JETTY_HOME/context/test.xml |
| 246 | ==== |
| 247 | |
Shawn O. Pearce | ce0cb8b | 2009-05-08 16:22:59 -0700 | [diff] [blame] | 248 | Edit `'$JETTY_HOME'/contexts/gerrit.xml` to correctly configure |
| 249 | the database and outgoing SMTP connections, especially the user |
| 250 | and password fields. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 251 | |
Shawn O. Pearce | ab583db | 2009-03-03 17:28:04 -0800 | [diff] [blame] | 252 | If OpenID authentication is being used, you may need to increase |
Shawn O. Pearce | ce0cb8b | 2009-05-08 16:22:59 -0700 | [diff] [blame] | 253 | the header buffer size parameter, due to very long header lines. |
| 254 | Add the following to `'$JETTY_HOME'/etc/jetty.xml` under |
Shawn O. Pearce | ab583db | 2009-03-03 17:28:04 -0800 | [diff] [blame] | 255 | `org.mortbay.jetty.nio.SelectChannelConnector`: |
| 256 | |
| 257 | ==== |
| 258 | <Set name="headerBufferSize">16384</Set> |
| 259 | ==== |
| 260 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 261 | To start automatically when the system boots, consider a start |
| 262 | script such as the following in `/etc/init.d/gerrit2-jetty` |
| 263 | |
| 264 | ==== |
| 265 | #!/bin/sh |
| 266 | |
| 267 | export JETTY_HOST=127.0.0.1 |
| 268 | export JETTY_PORT=8081 |
| 269 | export JETTY_USER=gerrit2 |
| 270 | export JETTY_PID=/var/run/jetty$JETTY_PORT.pid |
| 271 | export JETTY_HOME=/home/$JETTY_USER/jetty |
| 272 | export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.07/jre |
| 273 | |
| 274 | JAVA_OPTIONS="" |
| 275 | JAVA_OPTIONS="$JAVA_OPTIONS -Djetty.host=$JETTY_HOST" |
| 276 | export JAVA_OPTIONS |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 277 | |
Shawn O. Pearce | b546c9b | 2009-02-24 13:12:39 -0800 | [diff] [blame] | 278 | C="jetty-logging jetty" |
| 279 | [ -f "$JETTY_HOME/etc/jetty_sslproxy.xml" ] && C="$C jetty_sslproxy" |
| 280 | |
| 281 | exec $JETTY_HOME/bin/jetty.sh "$@" $C |
| 282 | ==== |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 283 | |
| 284 | [TIP] |
| 285 | Under Jetty, restarting the web application (e.g. after modifying |
Shawn O. Pearce | ce0cb8b | 2009-05-08 16:22:59 -0700 | [diff] [blame] | 286 | `system_config`) is as simple as touching the context config file: |
| 287 | `'$JETTY_HOME'/contexts/gerrit.xml` |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 288 | |
Shawn O. Pearce | b546c9b | 2009-02-24 13:12:39 -0800 | [diff] [blame] | 289 | Port 80 |
| 290 | ^^^^^^^ |
| 291 | |
| 292 | To deploy on port 80, you should configure Jetty to listen on another |
| 293 | port, such as 127.0.0.1:8081 (like the start script above does) |
| 294 | and then follow the <<apache2,reverse proxy>> section below. |
| 295 | |
| 296 | Port 443 (HTTPS / SSL) |
| 297 | ^^^^^^^^^^^^^^^^^^^^^^ |
| 298 | |
| 299 | To deploy on port 443 with SSL enabled, unpack the SSL proxy handling |
Shawn O. Pearce | ce0cb8b | 2009-05-08 16:22:59 -0700 | [diff] [blame] | 300 | rule into `'$JETTY_HOME'/etc`: |
Shawn O. Pearce | b546c9b | 2009-02-24 13:12:39 -0800 | [diff] [blame] | 301 | ==== |
| 302 | java -jar gerrit.war --cat extra/jetty_sslproxy.xml >$JETTY_HOME/etc/jetty_sslproxy.xml |
| 303 | ==== |
| 304 | |
| 305 | Create a start script like the one above, configuring Jetty to |
| 306 | listen on another port, such as 127.0.0.1:8081. |
| 307 | |
| 308 | Set `canonical_url` in `system_config` to an `https://` style URL |
| 309 | for your application, so that non-SSL connections are automatically |
| 310 | upgraded to SSL by issuing a redirect. Gerrit does not currently |
| 311 | support a dual http/https usage on the same site as it doesn't |
| 312 | know when to upgrade a non-secure connection to a secure one if |
| 313 | data needs to be protected. |
| 314 | |
| 315 | Follow the <<apache2,reverse proxy>> section below to setup an |
| 316 | Apache2 server to handle SSL for Jetty. |
| 317 | |
| 318 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 319 | Other Servlet Containers |
| 320 | ~~~~~~~~~~~~~~~~~~~~~~~~ |
| 321 | |
Shawn O. Pearce | b8527ea | 2009-02-02 15:39:12 -0800 | [diff] [blame] | 322 | Deploy the `gerrit-*.war` file to your application server as |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 323 | `gerrit.war`. |
| 324 | |
| 325 | Configure the JNDI DataSource `jdbc/ReviewDb` for the Gerrit web |
| 326 | application context to point to the database you just created. |
| 327 | Don't forget to ensure your JNDI configuration can load the |
| 328 | necessary JDBC drivers. |
| 329 | |
Shawn O. Pearce | 933fcd9 | 2009-02-06 14:38:11 -0800 | [diff] [blame] | 330 | ('Optional') Add Bouncy Castle Crypto API to the web application's |
| 331 | classpath. Usually its best to load this library from the servlet |
| 332 | container's extensions directory, but gerrit.war could also be |
Shawn O. Pearce | ce0cb8b | 2009-05-08 16:22:59 -0700 | [diff] [blame] | 333 | manually repacked to include it. |
Shawn O. Pearce | 933fcd9 | 2009-02-06 14:38:11 -0800 | [diff] [blame] | 334 | |
Shawn O. Pearce | 92a19d2 | 2009-01-13 13:27:59 -0800 | [diff] [blame] | 335 | ('Optional') Configure the JNDI name `mail/Outgoing` for the web |
| 336 | application context to be a factory for a `javax.mail.Session`, |
| 337 | with the connection information necessary to send outgoing emails. |
| 338 | You may need to download and install the Java Mail JARs in your |
| 339 | container's classpath. If this is not configured, Gerrit will |
| 340 | function, but will not be able to send email. |
| 341 | |
Shawn O. Pearce | b546c9b | 2009-02-24 13:12:39 -0800 | [diff] [blame] | 342 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 343 | [[apache2]] |
| 344 | Apache2 Reverse Proxy |
| 345 | ~~~~~~~~~~~~~~~~~~~~~ |
| 346 | |
| 347 | Enable the necessary Apache2 modules: |
| 348 | |
| 349 | ==== |
| 350 | a2enmod proxy_http |
| 351 | a2enmod disk_cache ; # optional, but helps performance |
Shawn O. Pearce | b546c9b | 2009-02-24 13:12:39 -0800 | [diff] [blame] | 352 | |
| 353 | a2enmod ssl ; # optional, needed for HTTPS / SSL |
| 354 | a2enmod headers ; # optional, needed for HTTPS / SSL |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 355 | ==== |
| 356 | |
| 357 | then setup a VirtualHost to proxy to Gerrit's servlet container, |
| 358 | setting the `ProxyPass` line to use the port number you configured |
| 359 | in your servlet container's configuration: |
| 360 | |
| 361 | ======================================= |
| 362 | <VirtualHost *> |
| 363 | ServerName review.example.com |
| 364 | # |
| 365 | ProxyRequests Off |
| 366 | ProxyVia Off |
| 367 | ProxyPreserveHost On |
| 368 | # |
| 369 | <Proxy *> |
| 370 | Order deny,allow |
| 371 | Allow from all |
| 372 | </Proxy> |
| 373 | ProxyPass / http://127.0.0.1:8081/ |
| 374 | # |
| 375 | <IfModule mod_disk_cache.c> |
| 376 | CacheEnable disk / |
| 377 | CacheIgnoreHeaders Set-Cookie |
| 378 | </IfModule> |
| 379 | </VirtualHost> |
| 380 | ======================================= |
| 381 | |
Shawn O. Pearce | b546c9b | 2009-02-24 13:12:39 -0800 | [diff] [blame] | 382 | if you are using SSL with a Jetty container: |
| 383 | |
| 384 | ==== |
| 385 | <VirtualHost *:443> |
| 386 | ServerName review.example.com |
| 387 | # |
| 388 | SSLEngine on |
| 389 | SSLCertificateFile conf/server.crt |
| 390 | SSLCertificateKeyFile conf/server.key |
| 391 | # |
| 392 | ProxyRequests Off |
| 393 | ProxyVia Off |
| 394 | ProxyPreserveHost On |
| 395 | ProxyPass / http://127.0.0.1:8081/ |
| 396 | RequestHeader set X-Forwarded-Scheme https |
| 397 | # |
| 398 | <IfModule mod_disk_cache.c> |
| 399 | CacheEnable disk / |
| 400 | CacheIgnoreHeaders Set-Cookie |
| 401 | </IfModule> |
| 402 | </VirtualHost> |
| 403 | ==== |
| 404 | |
| 405 | See the Apache `mod_ssl` documentation for more details on how to |
| 406 | configure SSL within the server, like controlling how strong of an |
| 407 | encryption algorithm is required. |
| 408 | |
| 409 | For Gerrit, the only difference between plain HTTP and HTTPS is |
| 410 | adding the "`RequestHeader set X-Forwarded-Scheme https`" line |
| 411 | within the SSL enabled virtual host. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 412 | |
| 413 | |
| 414 | Administrator Setup |
| 415 | ------------------- |
| 416 | |
| 417 | Login to Gerrit through the web interface, so that a user account |
| 418 | is initialized for you. |
| 419 | |
| 420 | Add your newly created account to the "Administrators" group, |
| 421 | so that you can manage the site through the web interface: |
| 422 | |
| 423 | ==== |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 424 | INSERT INTO account_group_members |
| 425 | (account_id, group_id) |
| 426 | VALUES ( |
| 427 | (SELECT account_id FROM accounts |
| 428 | WHERE preferred_email='you@example.com'), |
| 429 | (SELECT admin_group_id FROM system_config) |
| 430 | ); |
| 431 | ==== |
| 432 | |
Shawn O. Pearce | 9ab6942 | 2009-02-06 14:49:44 -0800 | [diff] [blame] | 433 | You can also get your `account_id` from the web UI, under Settings, |
| 434 | if you don't want to use a SELECT subquery above, or your email |
| 435 | address wasn't prefilled automatically. |
| 436 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 437 | Group memberships are cached, so you need to either restart Gerrit, |
| 438 | or try flushing the caches over SSH. |
| 439 | |
| 440 | Since SSH cache flushing requires being in the "Administrators" |
| 441 | group you may run into a chicken-and-egg problem, where you cannot |
| 442 | flush the cache to make yourself an administrator because you are |
| 443 | not yet an administrator. Therefore, restarting the application |
| 444 | is the recommended bootstrap technique. |
| 445 | |
| 446 | To flush the server's caches over SSH, ensure you have an SSH key |
| 447 | (you can add one through the web UI under Settings, SSH Keys), |
| 448 | and then run: |
| 449 | |
| 450 | ==== |
| 451 | ssh -p 29418 you@example.com gerrit flush-caches |
| 452 | ==== |
| 453 | |
Shawn O. Pearce | 0b91a63 | 2009-02-06 12:53:59 -0800 | [diff] [blame] | 454 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 455 | Project Setup |
| 456 | ------------- |
| 457 | |
| 458 | See link:project-setup.html[Project Setup] for further details on |
| 459 | how to register a project with Gerrit. |