MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

Install and Configure Gerrit on CentOS and Ubuntu (MySQL + Apache Reverse Proxy)

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.

gerrit2-installation-configuration

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.

TaskCentOS/RHEL (typical)Ubuntu/Debian (typical)
Update package metadatasudo yum update -y (or dnf update -y)sudo apt-get update
Install Gitsudo yum install -y gitsudo apt-get install -y git
Install Screensudo yum install -y screensudo apt-get install -y screen
Install Javasudo yum install -y java-11-openjdksudo apt-get install -y openjdk-11-jre
Install Apachesudo yum install -y httpdsudo apt-get install -y apache2
Install MariaDB/MySQLsudo yum install -y mariadb-serversudo 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

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.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
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.

Related Posts

How to install & configure Apache HTTPD server in Linux?

Install & configure Apache HTTPD server in Ubuntu? Install & configure Apache HTTPD server in Centos/Redhat 7? Rajesh Kumar I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud,…

Read More

Installation Of Apache HTTP Web Server

How many ways you can install Apache? Installation Types1.Yum Based2.RPM Based3.Source code/ Tar ball Based Apache install on Centos 7 (Yum Base) 1.Check OS version # cat…

Read More

Datadog Log: Lab and Assignment

Lab Manual: Datadog Logs Search, Filter, Sorting, Display, and Analysis Hands-on Datadog Logs Explorer Lab using Ubuntu Linux Logs and Apache Logs Lab Objective By the end…

Read More

Ansible Installation and Configuration Guide

How to install ansible in Ubuntu? How to install ansible in Centos 7 / RHEL 7? How to install ansible in Centos 8 / RHEL 8? How…

Read More

Java Installation Guide in Linux & Windows

DOWNLOAD OPEN JDK & JRE JAVA PACKAGE FROM – https://jdk.java.net/archive/ Download and Install JDK/JRE 7 in Centos & RHEL Download and Install JDK/JRE 8 in Centos &…

Read More

Docker Tutorials: Installation and Configurations

Docker Installation in Centos/RHEL Method -1: How to install Docker Community Edition via YUM? Step 1 – Install required packages. yum-utils provides the yum-config-manager utility, and device-mapper-persistent-data…

Read More
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Puja kushwaha
Puja kushwaha
26 days ago

Gerrit is most effective when code reviews become a regular part of the development workflow. During setup, it is worth checking SSH access, user permissions, and Git integration on both supported Linux environments. Clear project rules and reviewer roles can help teams avoid delays and confusion. It is also useful to test a full change submission and approval cycle before inviting the whole team. These checks make the review process easier to manage and maintain.

1
0
Would love your thoughts, please comment.x
()
x