Originally published on 2015-11-21; fully revised and updated.
This guide walks DevOps and platform engineers through a clean Gerrit installation flow on Linux, based on the original CentOS/Ubuntu post and expanded into a production-oriented checklist. You will install prerequisites, configure MySQL/MariaDB, initialize Gerrit, place Apache in front as a reverse proxy, and verify that the service is reachable.

Installation workflow at a glance
Use this sequence to keep installation and troubleshooting predictable.
flowchart TD
A[Update OS packages] --> B[Install Git Java and tools]
B --> C[Provision MySQL database]
C --> D[Download Gerrit WAR]
D --> E[Run Gerrit init]
E --> F[Start Gerrit service]
F --> G[Configure Apache reverse proxy]
G --> H[Verify web and logs]
Prerequisites and planning
- A Linux host (CentOS/RHEL or Ubuntu/Debian) with sudo access.
- DNS or host mapping for the Gerrit URL you plan to expose via Apache.
- Open network access for HTTP/HTTPS (and SSH for Gerrit if you plan to use it).
- A Java runtime version supported by your chosen Gerrit release.
- A database backend (the original post used MySQL-family tooling).
Important: the original post references Gerrit 2.9.1. Treat that as a legacy example and select a currently supported Gerrit release from official documentation before production rollout.
Install base packages on CentOS/RHEL and Ubuntu/Debian
The package names and service names can differ by distribution and version. The table below provides a practical mapping for common setups.
| Task | CentOS/RHEL (typical) | Ubuntu/Debian (typical) |
|---|---|---|
| Update package metadata | sudo yum update -y (or dnf update -y) | sudo apt-get update |
| Install Git | sudo yum install -y git | sudo apt-get install -y git |
| Install Screen | sudo yum install -y screen | sudo apt-get install -y screen |
| Install Java | sudo yum install -y java-11-openjdk | sudo apt-get install -y openjdk-11-jre |
| Install Apache | sudo yum install -y httpd | sudo apt-get install -y apache2 |
| Install MariaDB/MySQL | sudo yum install -y mariadb-server | sudo apt-get install -y mariadb-server |
# CentOS/RHEL example
sudo yum update -y
sudo yum install -y git screen java-11-openjdk mariadb-server httpdCode language: PHP (php)
# Ubuntu/Debian example
sudo apt-get update
sudo apt-get install -y git screen openjdk-11-jre mariadb-server apache2Code language: PHP (php)
Create the Gerrit database (MySQL/MariaDB example)
The original article includes MySQL as a setup step. The following SQL creates a dedicated database and user for Gerrit.
sudo mysql -u root -p
CREATE DATABASE gerritdb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'gerrit'@'localhost' IDENTIFIED BY 'change_me';
GRANT ALL PRIVILEGES ON gerritdb.* TO 'gerrit'@'localhost';
FLUSH PRIVILEGES;Code language: JavaScript (javascript)
Download and initialize Gerrit
The original post used a direct WAR download and interactive setup. The same pattern is shown below. Replace the legacy version with your chosen release.
sudo useradd --system --home /opt/gerrit --create-home --shell /bin/bash gerrit
sudo su - gerrit
cd /opt/gerrit
wget https://gerrit-releases.storage.googleapis.com/gerrit-2.9.1.war
java -jar gerrit-2.9.1.war init --site-path /opt/gerrit/review_siteCode language: JavaScript (javascript)
Start, stop, and restart Gerrit
cd /opt/gerrit/review_site
./bin/gerrit.sh start
./bin/gerrit.sh stop
./bin/gerrit.sh restart
Install Apache and configure reverse proxy to Gerrit
Placing Apache in front of Gerrit gives you a standard entry point for HTTP/HTTPS and simplifies endpoint management.
<VirtualHost *:80>
ServerName gerrit.example.com
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
</VirtualHost>Code language: HTML, XML (xml)
# Ubuntu/Debian
sudo a2enmod proxy proxy_http headers
sudo systemctl restart apache2
# CentOS/RHEL
sudo systemctl enable httpd
sudo systemctl restart httpdCode language: PHP (php)
Verification checklist
# Gerrit backend port
ss -lntp | grep 8080
# Direct backend response
curl -I http://127.0.0.1:8080/
# Apache front-end response
curl -I http://127.0.0.1/
# Gerrit logs
tail -n 100 /opt/gerrit/review_site/logs/error_logCode language: PHP (php)
References from the original post
- Screen command reference: http://www.tecmint.com/screen-command-examples-to-manage-linux-terminals/
- Gerrit quick install docs: https://gerrit-review.googlesource.com/Documentation/install-quick.html
- OpenStack review install docs: https://review.openstack.org/Documentation/install.html
- Legacy Gerrit docs URL: https://gerrit.googlecode.com/svn/documentation/2.0/install.html
- Additional legacy walkthroughs: http://dachary.org/?p=1716, https://www.rosehosting.com/blog/how-to-install-gerrit2-on-a-centos-7-linux-vps/, https://www.digitalocean.com/community/tutorials/how-to-install-gerrit-on-an-ubuntu-cloud-server
Common pitfalls
- Using an outdated Gerrit version from old tutorials without checking current support status.
- Java runtime mismatch with the selected Gerrit release.
- Database credentials created correctly but not entered correctly during Gerrit init.
- Apache proxy modules not enabled (common on Debian/Ubuntu).
- Troubleshooting from browser errors only instead of checking Gerrit and Apache logs together.
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services — all in one place.
Explore Hospitals