Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

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

Gerrit Performance Tuning Cheat Sheet: Workflow, Bottlenecks, and Practical Commands

A practical Gerrit performance guide for DevOps and platform engineers. Learn a repeatable tuning workflow, where bottlenecks usually appear, and which commands to run first.

Read More

Best & Most Popular 5 Code Editor for Ruby programming Language

In this tutorial im going to share Top 5 code editor for Ruby Programming language. It’s very helpfull for programmers. Top 5 Code editor for Ruby Programming…

Read More

How to build jobs in jenkins when a change is pushed to Bitbucket

    Bitbucket plugin is designed to offer integration between Bitbucket and Jenkins.   It exposes a single URI endpoint that you can add as a WebHook…

Read More

Unix background process job control command Cheatsheet

Rajesh Kumar 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…

Read More

Top 5 Open Source Code Management tools

In this tutorial im going to demonstrate about Tops 5 Open Source Code Management tools who helps to know more about open source code management tools. Nowadays…

Read More
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
1
0
Would love your thoughts, please comment.x
()
x