UbuntuUbuntu Based

How To Install phpPgAdmin on Ubuntu 22.04 LTS

Install phpPgAdmin on Ubuntu 22.04

In this tutorial, we will show you how to install phpPgAdmin on Ubuntu 22.04 LTS. Managing databases is a crucial aspect of web development and administration. PostgreSQL, a powerful open-source object-relational database management system, is widely used for its reliability, robustness, and feature-rich capabilities. While PostgreSQL provides a command-line interface for interacting with databases, a web-based graphical user interface (GUI) like phpPgAdmin can greatly simplify database management tasks.

phpPgAdmin is a free and open-source web application that provides a user-friendly interface for administering PostgreSQL databases. It allows you to create, modify, and delete databases, tables, views, functions, and more, all through an intuitive 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.

Prerequisites

  • 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.
  • 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 phpPgAdmin on Ubuntu 22.04 LTS Jammy Jellyfish

Step 1. It’s always a good practice to keep your system up-to-date with the latest security patches and bug fixes. Open your terminal and run the following commands to update the package lists and upgrade installed packages:

sudo apt update
sudo apt upgrade

This step ensures that your system is running the latest versions of packages, minimizing potential compatibility issues and security vulnerabilities.

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:

apache2 -v

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 is 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:

php --version

Output:

root@idroot.us:~# 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 the 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 http://your-domain.com/phppgadmin.

Congratulations! You have successfully installed phpPgAdmin. Thanks for using this tutorial for installing the phpPgAdmin web-based administration tool for PostgreSQL on the Ubuntu 22.04 LTS Jammy Jellyfish system. For additional help or useful information, we recommend you check the phpPgAdmin 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

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