blob: 9926b8fd0c0c1f8b4847b6d3dc70e277291e36ad [file] [log] [blame]
Shawn O. Pearcee31d02c2009-12-08 12:21:37 -08001Gerrit Code Review - Installation Guide
2=======================================
Shawn O. Pearced2b73db2009-01-09 11:55:47 -08003
Fredrik Luthander833aa742011-10-27 21:07:46 +02004[[requirements]]
5Requirements
Martin Fick472bb9d2012-05-08 16:30:16 -07006------------
Fredrik Luthander833aa742011-10-27 21:07:46 +02007To run the Gerrit service, the following requirements must be met on
8the host:
9
10* JDK, minimum version 1.6 http://www.oracle.com/technetwork/java/javase/downloads/index.html[Download]
11
12You'll also need a SQL database to house the review metadata. You have the
13choice of either using the embedded H2 or to host your own MySQL or PostgreSQL.
14
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080015
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -080016[[download]]
17Download Gerrit
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080018---------------
19
Shawn O. Pearce31af1ff2009-01-26 12:04:41 -080020Current and past binary releases of Gerrit can be obtained from
21the downloads page at the project site:
22
23* http://code.google.com/p/gerrit/downloads/list[Gerrit Downloads]
24
Shawn O. Pearce8ddb8cb2009-09-28 12:21:28 -070025Download 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
Anthonyd3aed4c2009-09-26 13:48:10 -040027rename the downloaded file.
Shawn O. Pearceb8527ea2009-02-02 15:39:12 -080028
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -080029If you would prefer to build Gerrit directly from source, review
30the notes under link:dev-readme.html[developer setup].
Shawn O. Pearce31af1ff2009-01-26 12:04:41 -080031
Fredrik Luthander833aa742011-10-27 21:07:46 +020032
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -080033[[createdb]]
34Database Setup
35--------------
Shawn O. Pearce31af1ff2009-01-26 12:04:41 -080036
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -080037[[createdb_h2]]
38H2
39~~
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080040
Fredrik Luthander833aa742011-10-27 21:07:46 +020041During the init phase of Gerrit you will need to specify which database to use.
42If you choose H2, Gerrit will automatically set up the embedded H2 database as
43backend so no set up in advance is necessary. Also, no additional configuration is
44necessary. Using the embedded H2 database is the easiest way to get a Gerrit
45site up and running, making it ideal for proof of concepts or small team
46servers. On the flip side, H2 is not the recommended option for large
47corporate installations. This is because there is no easy way to interact
48with the database while Gerrit is offline, it's not easy to backup the data,
49and it's not possible to set up H2 in a load balanced/hotswap configuration.
50
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080051
Fredrik Luthandera75dadc2011-10-28 06:58:18 +020052If this option interests you, you might want to consider link:install-quick.html[the quick guide].
53
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -080054[[createdb_postgres]]
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080055PostgreSQL
56~~~~~~~~~~
57
Fredrik Luthander833aa742011-10-27 21:07:46 +020058This option is more complicated than the H2 option but is recommended
59for larger installations. It's the database backend with the largest userbase
60in the Gerrit community.
61
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -080062Create a user for the web application within Postgres, assign it a
63password, create a database to store the metadata, and grant the user
64full rights on the newly created database:
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080065
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -080066----
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080067 createuser -A -D -P -E gerrit2
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080068 createdb -E UTF-8 -O gerrit2 reviewdb
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -080069----
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080070
Fredrik Luthander833aa742011-10-27 21:07:46 +020071
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -080072[[createdb_mysql]]
Shawn O. Pearce86816ee2009-05-13 17:37:20 -070073MySQL
74~~~~~
75
Fredrik Luthander833aa742011-10-27 21:07:46 +020076This option is also more complicated than the H2 option. Just as with
77PostgreSQL it's also recommended for larger installations.
78
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -080079Create a user for the web application within the database, assign it a
80password, create a database, and give the newly created user full
81rights on it:
Shawn O. Pearce86816ee2009-05-13 17:37:20 -070082
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -080083----
84 mysql
85
Shawn O. Pearce3e595632009-10-01 18:58:45 -070086 CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY 'secret';
Shawn O. Pearce86816ee2009-05-13 17:37:20 -070087 CREATE DATABASE reviewdb;
Shawn O. Pearce44174242009-10-29 11:09:18 -070088 ALTER DATABASE reviewdb charset=latin1;
Shawn O. Pearce86816ee2009-05-13 17:37:20 -070089 GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost';
Anthonyd3aed4c2009-09-26 13:48:10 -040090 FLUSH PRIVILEGES;
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -080091----
Shawn O. Pearce86816ee2009-05-13 17:37:20 -070092
Shawn O. Pearce0b91a632009-02-06 12:53:59 -080093
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -080094[[init]]
95Initialize the Site
96-------------------
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080097
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -080098Gerrit stores configuration files, the server's SSH keys, and the
99managed Git repositories under a local directory, typically referred
100to as `'$site_path'`. If the embedded H2 database is being used,
101its data files will also be stored under this directory.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800102
Fredrik Luthander833aa742011-10-27 21:07:46 +0200103You also have to decide where to store your server side git repositories. This
104can either be a relative path under `'$site_path'` or an absolute path
105anywhere on your server system. You have to choose a place before commencing
106your init phase.
107
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800108Initialize a new site directory by running the init command, passing
109the 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
111own user account on the host system:
112
113----
114 sudo adduser gerrit2
115 sudo su gerrit2
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800116
Fredrik Luthander833aa742011-10-27 21:07:46 +0200117 java -jar gerrit.war init -d /path/to/your/gerrit_application_directory
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800118----
119
Fredrik Luthander833aa742011-10-27 21:07:46 +0200120'Please note:' If you choose a location where your new user doesn't
121have any privileges, you may have to manually create the directory first and
122then give ownership of that location to the `'gerrit2'` user.
123
124If run from an interactive terminal, the init command will prompt through a
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800125series of configuration questions, including gathering information
Fredrik Luthander833aa742011-10-27 21:07:46 +0200126about the database created above. If the terminal is not interactive,
127running the init command will choose some reasonable default selections,
128and will use the embedded H2 database. Once the init phase is complete,
129you can review your settings in the file `'$site_path/etc/gerrit.config'`.
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800130
Fredrik Luthander833aa742011-10-27 21:07:46 +0200131When running the init command, additional JARs might be downloaded to
132support optional selected functionality. If a download fails a URL will
133be displayed and init will wait for the user to manually download the JAR
134and store it in the target location.
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800135
Fredrik Luthander833aa742011-10-27 21:07:46 +0200136When the init phase is complete, the daemon will be automatically started
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800137in 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
147When the browser opens, sign in to Gerrit through the web interface.
148The first user to sign-in and register an account will be
149automatically placed into the fully privileged Administrators group,
150permitting server management over the web and over SSH. Subsequent
151users will be automatically registered as unprivileged users.
152
153
Fredrik Luthander833aa742011-10-27 21:07:46 +0200154Installation Complete
155---------------------
156
157Your base Gerrit server is now installed and running. You're now ready to
158either set up more projects or start working with the projects you've already
159imported.
160
161
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800162[[project_setup]]
163Project Setup
164-------------
165
166See link:project-setup.html[Project Setup] for further details on
167how to register a new project with Gerrit. This step is necessary
168if existing Git repositories were not imported during 'init'.
169
170
Karsten Dambekalnsa7f72a22011-03-25 14:21:59 +0100171[[rc_d]]
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800172Start/Stop Daemon
173-----------------
174
175To control the Gerrit Code Review daemon that is running in the
176background, use the rc.d style start script created by 'init':
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800177
178====
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800179 review_site/bin/gerrit.sh start
180 review_site/bin/gerrit.sh stop
181 review_site/bin/gerrit.sh restart
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800182====
183
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800184('Optional') Link the gerrit.sh script into rc3.d so the daemon
185automatically starts and stops with the operating system:
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800186
187====
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800188 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. Pearce86816ee2009-05-13 17:37:20 -0700190====
191
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800192To install Gerrit into an existing servlet container instead of using
193the embedded Jetty server, see
194link:install-j2ee.html[J2EE installation].
Shawn O. Pearce86816ee2009-05-13 17:37:20 -0700195
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800196
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800197[[customize]]
198Site Customization
199------------------
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800200
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800201Gerrit Code Review supports some site-specific customization options.
David Pursehouse221d4f62012-06-08 17:38:08 +0900202For more information, see the related topics in this manual:
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800203
Francois Marierd550b462011-04-13 14:30:20 +1200204* link:config-reverseproxy.html[Reverse Proxy]
Shawn O. Pearcef384b442009-01-10 16:20:56 -0800205* link:config-sso.html[Single Sign-On Systems]
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800206* link:config-headerfooter.html[Site Header/Footer]
207* link:config-gitweb.html[Gitweb Integration]
Shawn O. Pearce7b405712009-05-08 18:27:53 -0700208* link:config-gerrit.html[Other System Settings]
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800209
Shawn O. Pearce0b91a632009-02-06 12:53:59 -0800210
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800211[[anonymous_access]]
212Anonymous Access
213----------------
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800214
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800215Exporting the Git repository directory
216(link:config-gerrit.html#gerrit.basePath[gerrit.basePath]) over the
217anonymous, unencrypted git:// protocol is more efficient than
218Gerrit's internal SSH daemon. See the `git-daemon` documentation
219for details on how to configure this if anonymous access is desired.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800220
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800221* http://www.kernel.org/pub/software/scm/git/docs/git-daemon.html[man git-daemon]
Shawn O. Pearceb546c9b2009-02-24 13:12:39 -0800222
223
Martin Fick472bb9d2012-05-08 16:30:16 -0700224[[plugins]]
225Plugins
226-------
227
228Place Gerrit plugins in the review_site/plugins directory to have them loaded on Gerrit startup.
229
230
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800231External Documentation Links
232----------------------------
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800233
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800234* 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. Pearced2b73db2009-01-09 11:55:47 -0800237
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700238
239GERRIT
240------
241Part of link:index.html[Gerrit Code Review]