Download any current *.war package. The war will be referred to as gerrit.war from this point forward, so you may find it easier to rename the downloaded file.
Initialize the Site
Gerrit stores configuration files, the server’s SSH keys, and the managed Git repositories under a local directory, typically referred to as ‘$site_path’.
Initialize a new site directory by running the init command, passing the path of the site directory to be created as an argument to the ‘-d’ option.
Its recommended that Gerrit Code Review be given its own user account on the host system:
1 2 3 4 5 6 7
# Create a new user called gerrit sudo adduser gerrit # Swith the privilages to root for gerrit user account and start it up:(inherit the environment variables from root) sudo su gerrit
# Initialize a new site directory for Gerrit: (replace /path/to/your/gerrit_application_directory with your actual path) java -jar gerrit.war init -d /path/to/your/gerrit_application_directory
Initial Configuration
I would like to show the whole process I’ve experienced here. Don’t worry, just follow my guidance.
1 2 3 4 5 6 7 8
# Create a new user called gerrit sudo adduser gerrit # Swith the privilages to root for gerrit user account and start it up:(inherit the environment variables from root) sudo su gerrit
# Make a new directory cd /home/gerrit mkdir gerrit_war
Then, download the gerrit.war from the Gerrit official site here as you want. Then, move the gerrit application to your gerrit directory.
1 2 3 4 5 6 7 8 9 10
[gerrit@gerrit2 gerrit_war]$ scp root@192.168.225.30:/home/gerrit/gerrit_war/gerrit-3.11.1.war . The authenticity of host '192.168.225.30 (192.168.225.30)' can't be established. ED25519 key fingerprint is SHA256:QZY7LFi5pVYhQHY56cn96boDi59JBU55x9o8/uyTlic. This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '192.168.225.30' (ED25519) to the list of known hosts. root@192.168.225.30's password: gerrit-3.11.1.war 100% 82MB 111.7MB/s 00:00 [gerrit@gerrit2 gerrit_war]$ ls gerrit-3.11.1.war
1 2 3
# Init the gerrir.war tarball cd /home/gerrit/gerrit_war java -jar gerrit-3.11.1.war init -d /home/gerrit/gerrit_application
The detailed information you could based on my settings and change it as you want.
[gerrit@gerrit2 gerrit_war]$ java -jar gerrit-3.11.1.war init -d /home/gerrit/gerrit_application Using secure store: com.google.gerrit.server.securestore.DefaultSecureStore [2025-03-11 15:07:00,893] [main] INFO com.google.gerrit.server.config.GerritServerConfigProvider : No /home/gerrit/gerrit_application/etc/gerrit.config; assuming defaults
*** Gerrit Code Review 3.11.1 ***
Create '/home/gerrit/gerrit_application' [Y/n]? Y
*** Git Repositories ***
Location of Git repositories [git]:
*** JGit Configuration ***
Auto-configured "receive.autogc = false" to disable auto-gc after git-receive-pack.
*** Index ***
Type [lucene]:
*** User Authentication ***
Authentication method [openid/?]: HTTP Get username from custom HTTP header [y/N]? N SSO logout URL : Enable signed push support [y/N]? N Use case insensitive usernames [Y/n]? Y
*** Review Labels ***
Install Verified label [y/N]? y
*** Email Delivery ***
SMTP server hostname [localhost]: *** SMTP server port [(default)]: ** SMTP encryption [none/?]: none SMTP username [gerrit]: ***@***.com ***@***.com's password : confirm password :
*** Container Process ***
Run as [gerrit]: gerrit Java runtime [/usr/lib/jvm/java-21-openjdk-21.0.6.0.7-1.el9.x86_64]: Copy gerrit-3.11.1.war to /home/gerrit/gerrit_application/bin/gerrit.war [Y/n]? Y Copying gerrit-3.11.1.war to /home/gerrit/gerrit_application/bin/gerrit.war
*** SSH Daemon ***
Listen on address [*]: Listen on port [29418]: Generating SSH host key ... rsa... ed25519... ecdsa 256... ecdsa 384... ecdsa 521... done
*** HTTP Daemon ***
Behind reverse proxy [y/N]? y Proxy uses SSL (https://) [y/N]? N Subdirectory on proxy server [/]: Listen on address [*]: Listen on port [8081]: 8080 Canonical URL [http://***/]: http://***
*** Cache ***
*** Plugins ***
Installing plugins. Install plugin codemirror-editor version v3.11.1 [y/N]? y Installed codemirror-editor v3.11.1 Install plugin commit-message-length-validator version v3.11.1 [y/N]? y Installed commit-message-length-validator v3.11.1 Install plugin delete-project version v3.11.1 [y/N]? y Installed delete-project v3.11.1 Install plugin download-commands version v3.11.1 [y/N]? y Installed download-commands v3.11.1 Install plugin gitiles version v3.11.1 [y/N]? y Installed gitiles v3.11.1 Install plugin hooks version v3.11.1 [y/N]? y Installed hooks v3.11.1 Install plugin plugin-manager version v3.11.1 [y/N]? y Installed plugin-manager v3.11.1 Install plugin replication version v3.11.1 [y/N]? y Installed replication v3.11.1 Install plugin replication-api version v3.11.1 [y/N]? y Installed replication-api v3.11.1 Install plugin reviewnotes version v3.11.1 [y/N]? y Installed reviewnotes v3.11.1 Install plugin singleusergroup version v3.11.1 [y/N]? y Installed singleusergroup v3.11.1 Install plugin webhooks version v3.11.1 [y/N]? y Installed webhooks v3.11.1 Initializing plugins.
Mar 11, 2025 3:09:49 PM org.apache.lucene.store.MemorySegmentIndexInputProvider <init> INFO: Using MemorySegmentIndexInput with Java 21; to disable start with -Dorg.apache.lucene.store.MMapDirectory.enableMemorySegments=false ============================================================================ Welcome to the Gerrit community
Find more information on the homepage: https://www.gerritcodereview.com Discuss Gerrit on the mailing list: https://groups.google.com/g/repo-discuss ============================================================================ Initialized /home/gerrit/gerrit_application Init complete, reindexing accounts,changes,groups,projects with: reindex --site-path /home/gerrit/gerrit_application --threads 1 --index accounts --index changes --index groups --index projectsReindexed 0 documents in accounts index in 0.0s (0.0/s) Index accounts in version 14 is ready Reindexing groups: 100% (3/3) Reindexed 3 documents in groups index in 0.3s (11.3/s) Index groups in version 11 is ready Reindexing changes: Slicing projects: 100% (2/2), done Reindexed 0 documents in changes index in 0.0s (0.0/s) Index changes in version 86 is ready Reindexing projects: 100% (2/2) Reindexed 2 documents in projects index in 0.1s (27.0/s) Index projects in version 9 is ready Executing /home/gerrit/gerrit_application/bin/gerrit.sh start Starting Gerrit Code Review: WARNING: Could not adjust Gerrit's process for the kernel's out-of-memory killer. This may be caused by /home/gerrit/gerrit_application/bin/gerrit.sh not being run as root. Consider changing the OOM score adjustment manually for Gerrit's PID=1859 with e.g.: echo '-1000' | sudo tee /proc/1859/oom_score_adj OK Waiting for server on 192.168.225.31:8080 ... OK Please open the following URL in the browser: http://192.168.225.31:8080/#/admin/projects/
Tips:
If you would like to use reverse-proxy, the Authentication method must be set as http. Other configurations could set as default, type enter to skip.
What’s more, please rememer to allow the 8080 port by using:
If you open the website in the browser(e.g. chrome), A pop-up window will appear asking you to enter your password.
Congratulations to you! Up to now, you have completed the whole process of deploying gerrit.
Please enjoy yourself in using such a code review application :D
Tips:
It is normal phenomenon if you could not sign out in the website.
Here is the reason: You are using HTTP Basic authentication. There is no way to tell a browser to quit sending basic authentication credentials, to logout with basic authentication is to close the Web browser.
What’s more, clear all cookies and data cache does work as well.
Copyright Notice: This article is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Please attribute the original author and source when sharing.