In this tutorial, we will show you how to install phpPgAdmin on Ubuntu 22.04 LTS. For those of you who didn’t know, PhpPgAdmin is an administration interface for PostgreSQL written in PHP. It allows you to manage your databases and perform various tasks, such as creating tables, managing users, and running SQL queries, all through a web interface.
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 phpPgAdmin 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 for phpPgAdmin.
non-root sudo useror 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 phpPgAdmin on Ubuntu 22.04 LTS Jammy Jellyfish
Step 1. First, make sure that all your system packages are up-to-date by running the following
apt commands in the terminal.
sudo apt update sudo apt upgrade
Step 2. Installing Apache HTTP Server.
By default, Apache is available on Ubuntu 22.04 base repository. Now run the following command below to install the latest version of Apache to your Ubuntu system:
sudo apt install apache2
After successful installation, enable Apache (to start automatically upon system boot), start, and verify the status using the commands below:
sudo systemctl enable apache2 sudo systemctl start apache2 sudo systemctl status apache2
You can confirm the Apache2 version with the below command:
For additional resources on installing and managing Apache, read the post below:
Step 3. Installing PHP.
By default, the PHP is not available on Ubuntu 22.04 base repository. Now run the following command below to add the Ondrej PPA to your system:
sudo add-apt-repository ppa:ondrej/php
After the repository was added, Update the APT index then install PHP 8.2 using the following command below:
sudo apt update sudo apt install php8.2 php8.2-cli php8.2-common php8.2-imap php8.2-redis php8.2-snmp php8.2-xml php8.2-zip php8.2-mbstring php8.2-curl libapache2-mod-php php8.2-mysql
Confirm the installation and check the installed build version of PHP:
email@example.com:~# php -v PHP 8.1.2-1ubuntu2.9 (cli) (built: Dec 16 2022 12:58:11) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.2, Copyright (c) Zend Technologies with Zend OPcache v8.1.2-1ubuntu2.9, Copyright (c), by Zend Technologies
Step 4. Installing PostgreSQL.
By default, PostgreSQL is available on Ubuntu 22.04 base repository. Now run the following command below to install the latest version of PostgreSQL to your system:
sudo apt install postgresql postgresql-contrib
Once successfully installed, enable PostgreSQL (to start automatically upon system boot), start, and verify the status using the commands below:
sudo systemctl enable postgresql sudo systemctl start postgresql sudo systemctl status postgresql
For additional resources on installing PostgreSQL, read the post below:
Step 4. Installing phpPgAdmin on Ubuntu 22.04.
To install phpPgAdmin, run the following command below:
sudo apt install phppgadmin php-pgsql
Next, open the phpPgAdmin configuration file
/etc/phppgadmin/config.inc.php with our favorite editor and make several changes to look like this:
$conf['extra_login_security'] = true; $conf['owned_only'] = true;
Step 5. Configure Apache Virtual Host.
Now create the virtual host configuration file for phpPgAdmin:
sudo nano /etc/apache2/sites-available/phppgadmin.conf
Add the following file:
<Directory /usr/share/phppgadmin> <IfModule mod_dir.c> DirectoryIndex index.php </IfModule> AllowOverride None # Only allow connections from localhost: #Require local <IfModule mod_php.c> php_flag magic_quotes_gpc Off php_flag track_vars On #php_value include_path . </IfModule> <IfModule !mod_php.c> <IfModule mod_actions.c> <IfModule mod_cgi.c> AddType application/x-httpd-php .php Action application/x-httpd-php /cgi-bin/php </IfModule> <IfModule mod_cgid.c> AddType application/x-httpd-php .php Action application/x-httpd-php /cgi-bin/php </IfModule> </IfModule> </IfModule> </Directory>
Now, we can restart the Apache webserver so that the changes take place:
sudo a2enmod rewrite sudo a2ensite phppgadmin.conf sudo systemctl restart apache2.service
Step 6. Configure Firewall.
Now we set up an Uncomplicated Firewall (UFW) with Apache to allow public access on default web ports for HTTP and HTTPS:
sudo ufw allow OpenSSH sudo ufw allow 'Apache Full' sudo ufw enable
Step 7. Accessing phpPgAdmin Web Interface.
Once successfully installed, now open your web browser and access the phpPgAdmin Web UI using the URL
Congratulations! You have successfully installed phpPgAdmin. Thanks for using this tutorial for installing the phpPgAdmin web-based administration tool for PostgreSQL on Ubuntu 22.04 LTS Jammy Jellyfish system. For additional help or useful information, we recommend you check the phpPgAdmin website.