How to Install phpPgAdmin on Debian 12

how to install and configure php opcache on ubuntu 22.04

phpPgAdmin is a web-based software that allows developers, system administrators, and regular users to manage their PostgreSQL database easily via the browser.PostgreSQL is an object-relational database management system.

phpPgAdmin is written in PHP and is based on the popular phpMyAdmin interface originally written for MySQL administration. This blog post will install PHP, PostgreSQL, and the Apache Web server to create an Apache configuration file for phpPgAdmin.

For this setup, we will spend up to 20 minutes. Let’s get things done!

Prerequisites

  • A server with Debian 12 as OS
  • User privileges: root or non-root user with sudo privileges

Step 1. Update the System

We assume that you have a fresh installation of Debian 12. That’s why we need to update the package to the latest versions available.

sudo apt-get update -y && sudo apt-get upgrade -y

Step 2. Install PHP

PHP8 with extensions and can be installed with the following commands:

sudo apt-get install php8.1 php8.1-cli php8.1-common php8.1-imap php8.1-redis php8.1-snmp php8.1-xml php8.1-zip php8.1-mbstring php8.1-curl libapache2-mod-php php8.1-mysql -y

To check the installed PHP version execute the command php -v

root@host:~# php -v
PHP 8.1.2-1ubuntu2.13 (cli) (built: Jun 28 2023 14:01:49) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2-1ubuntu2.13, Copyright (c), by Zend Technologies

Step 3. Install PostgreSQL

To install PostgreSQL on Debian 12, execute the following command:

sudo apt install postgresql postgresql-client

Once installed, start and enable the PostgreSQL service.

sudo systemctl enable postgresql.service && sudo systemctl start postgresql.service

Check if the service is up and running:

sudo systemctl status postgresql.service

You should receive the following output:

root@host:~# sudo systemctl status postgresql.service
● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
     Active: active (exited) since Tue 2023-08-08 14:29:49 CDT; 15s ago
   Main PID: 114670 (code=exited, status=0/SUCCESS)
        CPU: 2ms

Aug 08 14:29:49 host.test.vps systemd[1]: Starting PostgreSQL RDBMS...
Aug 08 14:29:49 host.test.vps systemd[1]: Finished PostgreSQL RDBMS.

Step 4. Install Apache Web Server

To install the Apache Web server execute the following command:

sudo apt install apache2 -y

Once installed, start and enable the service.

sudo systemctl enable apache2.service && sudo systemctl start apache2.service

Check if the service is up and running:

sudo systemctl status apache2.service

You should receive the following output:

root@host:~# sudo systemctl status apache2.service
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2023-08-08 14:47:17 CDT; 2s ago
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 100681 (apache2)
      Tasks: 7 (limit: 4557)
     Memory: 17.2M
        CPU: 17.842s
     CGroup: /system.slice/apache2.service
             ├─100681 /usr/sbin/apache2 -k start
             ├─111025 /usr/sbin/apache2 -k start

Step 5. Install phpPgAdmin

To install phpPgAdmin, execute the following command:

sudo apt install phppgadmin php-pgsql -y

Once the installation is complete, you need to open the phpPgAdmin configuration file /etc/phppgadmin/config.inc.php with our favorite editor. Find the above line and make sure to look like this:

$conf['owned_only'] = true;

Save the file and close it.

Step 6. Create an Apache Configuration file

We are at the final step now. Go into the following Apache directory and create the configuration file for the phpPgAdmin.

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS
cd /etc/apache2/conf-enabled/

touch phppgadmin.conf

Open the file, paste the following lines of code, save the file, and close it.

Alias /phppgadmin /usr/share/phppgadmin

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

Check the syntax:

apachectl -t

You should receive the following output:

root@vps:~# apachectl -t
Syntax OK

If the syntax is OK, restartd the Apache service.

systemctl reload apache2.service

Once the Apache service is restarted, you can access the phpPgAdmin at http://yourdomain.com/phppgadmin.

That’s it! You successfully installed phpPgAdmin on Debian 12. Of course, you do not have to install this if you find any difficulties. You can contact our technical support by submitting a support ticket or live chat. We are available 24/7

If you liked this post on how to phpPgAdmin on Debian 12, please share it with your friends on social networks or simply leave a reply below. Thanks.

Leave a Comment