UbuntuUbuntu Based

How To Install PgHero on Ubuntu 22.04 LTS

Install PgHero on Ubuntu 22.04

In this tutorial, we will show you how to install PgHero on Ubuntu 22.04 LTS. For those of you who didn’t know, PostgreSQL is a powerful open-source relational database management system known for its reliability, scalability, and performance. However, optimizing PostgreSQL performance can be a complex task, requiring careful monitoring and analysis of various metrics. This is where PgHero comes in – a comprehensive PostgreSQL performance monitoring tool that provides valuable insights into your database’s health and performance.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the PgHero performance dashboard for Postgres on Ubuntu 22.04 (Jammy Jellyfish). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.


  • A server running one of the following operating systems: Ubuntu 22.04, 20.04, and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install PgHero on Ubuntu 22.04 LTS Jammy Jellyfish

Step 1. To ensure a smooth installation process, it’s crucial to update your system packages to their latest versions. This step helps prevent potential compatibility issues and security vulnerabilities. Open your terminal and run the following commands:

sudo apt update
sudo apt upgrade

Step 2. Installing PostgreSQL.

PgHero requires PostgreSQL to be installed on your system. If you already have PostgreSQL set up, you can skip this step. Otherwise, follow these instructions to install PostgreSQL on Ubuntu 22.04 LTS:

First, add the PostgreSQL apt repository to your system by running the following command:

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

Import the repository signing key to ensure the authenticity of the packages:

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

Install the latest version of PostgreSQL along with the contrib package:

sudo apt update
sudo apt install postgresql postgresql-contrib

Verify the installation by checking the PostgreSQL version:

psql --version

Step 3. Configure PostgreSQL.

To set up PgHero, we need to create a dedicated PostgreSQL user and database. Follow these steps to configure PostgreSQL:

Switch to the postgres user to access the PostgreSQL prompt:

sudo -u postgres psql

Create a new PostgreSQL user for PgHero:

CREATE USER pghero WITH PASSWORD 'your_password';

Create a new database for PgHero:

CREATE DATABASE pghero_db OWNER pghero;

Exit the PostgreSQL prompt:


Open the PostgreSQL configuration file pg_hba.conf using a text editor with sudo privileges:

sudo nano /etc/postgresql/14/main/pg_hba.conf

Note: The path to pg_hba.conf may vary depending on your PostgreSQL version.

Add the following line to the end of the file to allow the pghero user to connect to the database:

local pghero_db pghero md5

Save and close the file, then restart PostgreSQL for the changes to take effect:

sudo systemctl restart postgresql

Step 4. Installing PgHero Dependencies.

PgHero relies on certain dependencies to function properly. Let’s install them using the following commands:

sudo apt install ruby ruby-dev build-essential libpq-dev

Install the bundler gem:

sudo gem install bundler

Step 5. Installing PgHero on Ubuntu 22.04.

There are multiple ways to install PgHero, including using Docker, installing it as a Linux package, or integrating it as a Rails engine. In this tutorial, we’ll focus on installing PgHero as a Linux package. Here’s how to do it:

Add the PgHero apt repository to your system:

sudo sh -c 'echo "deb https://dl.packager.io/srv/pghero/pghero/deb/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/pghero.list'

Import the repository signing key:

wget -O- https://dl.packager.io/srv/pghero/pghero/key | sudo apt-key add -

Next, install the pghero package:

sudo apt update
sudo apt install pghero

Configure PgHero by setting the DATABASE_URL environment variable:

export DATABASE_URL="postgres://pghero:your_password@localhost:5432/pghero_db"

Start the PgHero server:

pghero config:set DATABASE_URL=$DATABASE_URL
pghero server

Step 6. Access the PgHero Dashboard.

Now that PgHero is up and running, you can access its dashboard to gain insights into your PostgreSQL database performance. By default, PgHero listens on port 8080. To access the dashboard, open your web browser and navigate to:


If you prefer to use a different port for PgHero, you can specify it when starting the server:

pghero server -p custom_port

Install PgHero on Ubuntu 22.04 LTS Jammy Jellyfish

The PgHero dashboard provides a wealth of information about your PostgreSQL database, including query performance, index usage, table statistics, and more. Take some time to explore the various sections and familiarize yourself with the available metrics and insights.

Congratulations! You have successfully installed PgHero. Thanks for using this tutorial for installing the PgHero performance dashboard for Postgres on Ubuntu 22.04 LTS Jammy Jellyfish system. For additional help or useful information, we recommend you check the PgHero website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button