GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
* Sign Up! *

Support
Customer Portal
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

PostgreSQL: Relational Database Server

bullet Introduction

PostgreSQL is a powerful, open-source object-relational database server with over thirty-five years of active development behind it. It is known for standards compliance, reliability, and an advanced feature set — transactional DDL, rich data types (JSON, arrays, ranges), full-text search, and sophisticated indexing — and it is the database many modern frameworks and applications reach for first. It runs well on both FreeBSD 15 and Rocky Linux 10.

If your application instead documents MySQL-compatible databases, see the MariaDB and MySQL pages.

 

bullet Installation

Connect to your VPS, become root, install the server and client, initialize the data directory, and start the service. (Package versions move over time — a quick pkg search postgresql or dnf search postgresql confirms the current names.)

On FreeBSD 15:

# pkg install postgresql18-server postgresql18-client
# sysrc postgresql_enable=YES
# service postgresql initdb
# service postgresql start

On Rocky Linux 10:

# dnf install postgresql-server
# postgresql-setup --initdb
# systemctl enable --now postgresql

Unlike MariaDB, there is no separate hardening script to run: PostgreSQL's out-of-the-box posture is already conservative. The server listens only on localhost, and local connections authenticate as the matching system user ("peer" authentication) — so only the postgres system account can initially administer the database.

 

bullet Creating a Database and User

Give each application its own database and a dedicated database user (PostgreSQL calls these "roles"). Never put the postgres superuser into an application's configuration file. Become the postgres system account, then create the role and its database:

# su - postgres
$ createuser --pwprompt myapp
$ createdb --owner myapp myapp

Or do the same from the interactive psql client:

CREATE USER myapp WITH PASSWORD 'choose-a-strong-password';
CREATE DATABASE myapp OWNER myapp;

The application then connects as myapp to the myapp database on localhost. Keeping the server bound to localhost (its default) means it is reachable only from the VPS itself, not the open Internet — the right posture for a typical single-server site.

 

bullet Connecting from Your Application

Most PHP applications talk to PostgreSQL through PHP's pgsql or PDO extensions, installed alongside PHP (php84-pgsql on FreeBSD, php-pgsql on Rocky Linux); Perl and Python use DBD::Pg and psycopg. In the application's configuration you will typically supply four things — host (localhost), database name, user, and password — matching what you created above.

Password logins over TCP are governed by pg_hba.conf (in /var/db/postgres/data18/ on FreeBSD, /var/lib/pgsql/data/ on Rocky Linux). If your application's password is refused, make sure the host lines for 127.0.0.1 use scram-sha-256, then reload the service.

On Rocky Linux, SELinux blocks Apache from opening network connections by default. A local socket is fine, but if your app connects to PostgreSQL over TCP (including 127.0.0.1), allow it once:

# setsebool -P httpd_can_network_connect_db on

 

bullet Backups

A database is not captured usefully by a plain file copy while the server is running; dump it to a SQL file instead. pg_dump writes a complete, restorable snapshot of one database, and pg_dumpall captures the whole cluster including roles:

# Back up one database (as the postgres user)
$ pg_dump myapp > myapp-`date +%F`.sql

# Restore it
$ psql myapp < myapp-2026-07-25.sql

Schedule the dump from cron and copy the result off the VPS as part of the routine on the Server Maintenance page, so a database failure never costs you more than a day's data.

 

bullet Web Administration with pgAdmin

pgAdmin is the standard graphical administration tool for PostgreSQL. From a browser or as a desktop application it lets you create and browse databases, run SQL, import and export data, and manage roles — a friendly alternative to the command-line client. The simplest and safest arrangement is to run pgAdmin on your own workstation and reach the database through an SSH tunnel, so nothing extra is exposed on the VPS:

$ ssh -L 5432:localhost:5432 user@your-vps.example.com

Then point pgAdmin at localhost:5432 on your workstation and log in with a database user — the per-application account for everyday work, or postgres for administration.

TIP: Any tool that talks directly to your database is a high-value target. Prefer the SSH-tunnel arrangement above to hosting an administration interface on the VPS itself, keep PostgreSQL bound to localhost, and patch the server as part of Securing Your VPS. For occasional work, the command-line psql client over SSH is the safest option of all.

 

bullet Documentation

The psql(1) and pg_dump(1) manual pages cover the client tools. The project's own manual is exceptionally thorough, and its news page announces each release:


Toll Free 1-866-GSP-4400 • 1-301-464-9363 • service@gsp.com
Copyright © 1994-2026 GSP Services, Inc.