Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › Database administration

How to Install and Configure PostGIS on a Linux VPS

By Freedom251 Team · · 10 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install PostGIS as a PostgreSQL-major-matched package on your Ubuntu or Debian VPS, then enable it separately in the application database that will store spatial data. For example, PostgreSQL 18 uses postgresql-18-postgis-3; replace 18 with the major version actually running on your server. After creating a dedicated database, run CREATE EXTENSION postgis; and verify it with SELECT postgis_full_version();.

The important distinction is between server installation and database enablement. Apt installs the files for a particular PostgreSQL cluster, but the extension becomes usable only in databases where you create it. The procedure below covers self-managed Ubuntu and Debian VPSs, multiple installed PostgreSQL clusters, optional PostGIS modules, managed PostgreSQL services, and the errors most often caused by mismatched versions or connecting to the wrong port.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What you need before installing PostGIS

PostGIS is a PostgreSQL extension, not a separate database server. Your installation must therefore match three things: the Linux distribution, the PostgreSQL major version, and the cluster you intend to use. Installing a package for one major while connecting to another is the most common cause of an apparently missing extension.

Self-managed or managed PostgreSQL?

On a self-managed VPS, you control apt repositories, PostgreSQL packages, clusters, ports, roles, and configuration files. The Ubuntu/Debian commands in this guide apply to that model. A managed PostgreSQL service may already have the PostGIS files installed. In that case, do not install operating-system packages; check the provider’s supported-extension list and proceed directly to database-level enablement if PostGIS is offered.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Prerequisites

  • An Ubuntu or Debian VPS with administrator access through sudo.
  • A supported distribution release and architecture for the PostgreSQL packages you plan to use.
  • A decision about the PostgreSQL major version required by your application.
  • Network access to the PostgreSQL instance and credentials for a PostgreSQL administrator or another role allowed to create extensions.
  • A dedicated application database name, such as gisdb. Do not use the default postgres maintenance database as your application spatial database.

Record the operating-system release codename, architecture, PostgreSQL major, cluster name, port, and target database in your deployment notes. Debian-style packaging allows several PostgreSQL majors to coexist, so an unqualified command such as psql can otherwise connect to a different cluster than the one you just installed.

Choose Ubuntu/Debian packages or PGDG

Ubuntu and Debian publish PostgreSQL and extension packages in their own release repositories. Those packages are convenient when the distribution’s PostgreSQL major fits your application and its support window. The PostgreSQL Global Development Group (PGDG) repository is the alternative when you need a supported major that is not in the distribution snapshot or when you want the package stream maintained for that major.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Decision Use distribution packages when Use PGDG when
PostgreSQL major The major supplied for your Ubuntu or Debian release is the one your application requires. You need a different supported major than the distribution currently publishes.
Repository setup The standard apt sources are sufficient; no additional repository is required. You add the PGDG repository, signing key, release codename, and architecture before installing.
Package naming Use the same versioned names, such as postgresql-18 and postgresql-18-postgis-3, if that is the selected major. Use the PGDG package for that exact major and the corresponding postgresql-<major>-postgis-3 package.
Lifecycle fit Best when the VPS distribution’s support period and PostgreSQL lifecycle meet your operational requirements. Best when the distribution snapshot is too old or does not contain the required major.
Architecture Install packages available for the VPS architecture. Confirm that PGDG publishes the selected major for the VPS architecture before changing repositories.

Do not choose a package because its name looks close to your running version. The number in postgresql-18-postgis-3 is the PostgreSQL major, not a cosmetic label. Check the actual running cluster with pg_lsclusters before deciding which number to substitute.

Adding PGDG with the documented setup script

If the distribution repository does not provide the desired major, install the PostgreSQL repository helper and run the documented setup script:

sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh

The script configures the PGDG apt source for the system. Review the output and then use the versioned package name for the major you selected.

Manual PGDG repository setup

A manual setup follows the same principles: install curl and ca-certificates, import the PGDG signing key, create /etc/apt/sources.list.d/pgdg.sources, set the exact distribution codename with the -pgdg suffix, specify the VPS architecture, and run sudo apt update. Use the codename reported by the VPS itself rather than copying an example for another release. A repository entry for the wrong codename can produce missing packages or a mixture of incompatible distribution metadata.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Install PostgreSQL and PostGIS

Once the correct apt source is available, install PostgreSQL and the major-matched PostGIS server package. The PostGIS installation guide shows PostgreSQL 18 as an example:

sudo apt update
sudo apt install postgresql-18 postgresql-18-postgis-3
sudo apt install postgis

Replace every 18 with the major you selected. The versioned package supplies the PostGIS server extension for that PostgreSQL major. The unversioned postgis package supplies command-line utilities, including shp2pgsql and raster2pgsql, which are useful when importing shapefiles or raster data.

Installing the server package does not automatically add PostGIS to every database. It places the extension files where the matching PostgreSQL installation can find them; you still have to run CREATE EXTENSION in each database that needs spatial types and functions.

Check what apt installed

After installation, confirm that the package name contains the same major as the cluster you intend to run. If you installed postgresql-18-postgis-3 but the active cluster is PostgreSQL 16, the 16 cluster will not necessarily see the 18 package’s extension files. Resolve that mismatch before attempting SQL enablement.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Find the active cluster and port

On Ubuntu and Debian installations managed by the Debian PostgreSQL tooling, run:

pg_lsclusters

The output identifies each PostgreSQL major, cluster name, status, port, owner, and data directory. Use it to answer four practical questions:

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord | 6.35mm Jack, Durable Design, Stage and Home Studio Use, Low Noise Shielded Electric Cord for Bass, Keyboard, Amp, Mixer
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
  • Which major is running?
  • Is the intended cluster online?
  • What port should your client use?
  • Are multiple clusters installed, and could your client be reaching the wrong one?

For example, a machine can have one cluster for an older application and another for a newly installed major. Both can be valid, but a package installed for one does not enable PostGIS in the other. When connecting, specify the reported port and database explicitly rather than relying on defaults.

Connect to a specific cluster

Use the PostgreSQL client with the target database, role, host, and port appropriate to your setup. A local administrator connection commonly looks like this:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo -u postgres psql -p <port> -d postgres

Replace <port> with the port shown by pg_lsclusters. The postgres database in this command is only the maintenance connection used to create the application database; it is not the database in which you should deploy your application’s spatial schema.

Create a dedicated spatial database and enable PostGIS

Connect as the PostgreSQL administrator, create the application database, switch to it, and create the extension:

CREATE DATABASE gisdb;
connect gisdb
CREATE EXTENSION postgis;

After CREATE EXTENSION succeeds, the database has PostGIS’s spatial types, functions, operators, and metadata tables available. Extension installation is database-local: if your server has gisdb, reporting, and staging, you must enable PostGIS separately in every database that genuinely stores or queries spatial data.

Use the application role after enablement

Use an administrator or provider-approved privileged role for the one-time extension creation. Then grant your application role only the database and schema privileges it needs. Keep administrative credentials out of application configuration and run migrations through a controlled deployment account. The exact role and grant model depends on your application, but the key boundary remains the same: package installation is an operating-system task, while extension creation is a database task.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

Why the default postgres database is the wrong target

The default postgres database is intended for maintenance connections. Installing PostGIS there can make an initial test appear successful while leaving the real application database unchanged. Creating gisdb (or another purpose-specific name) keeps spatial objects, ownership, backups, and permissions aligned with the application that uses them.

Add optional PostGIS modules only when required

Core PostGIS is enabled with CREATE EXTENSION postgis;. Additional capabilities are separate extensions and should be enabled only for a real workload:

CREATE EXTENSION postgis_raster;
CREATE EXTENSION postgis_topology;
CREATE EXTENSION postgis_sfcgal;
  • postgis_raster: enable when the application needs PostGIS raster data and functions.
  • postgis_topology: enable when you are using the topology model rather than ordinary geometry or geography columns.
  • postgis_sfcgal: enable when your workload requires the SFCGAL-backed operations and the corresponding package support is present.

These modules are independent database extensions. Creating the core extension does not silently activate all of them, and adding unused modules increases the amount of functionality you must understand and maintain.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Verify that PostGIS is installed and usable

Run both checks in the target application database, not only in the maintenance database:

SELECT postgis_full_version();
SELECT * FROM pg_available_extensions WHERE name = 'postgis';

Interpret postgis_full_version()

The first query reports the installed PostGIS build and its linked component versions. Save the output with your deployment record so that future upgrades can be compared against a known working state. A successful result confirms that the database can execute PostGIS’s version function.

Interpret pg_available_extensions

The availability query shows whether PostgreSQL can find the postgis extension files for the cluster to which you are connected. If the row is absent, the server cannot see a suitable installation for that running major, even if an apt command succeeded on the same VPS.

Confirm the extension is installed in this database

Availability and installation are different states. The availability view tells you that the files can be used; the successful CREATE EXTENSION postgis; command tells you that this database has the extension registered. Run the version query after switching to the application database to avoid validating the wrong connection.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configure an apt-installed PostgreSQL cluster

For apt installations, PostgreSQL configuration is organized below:

/etc/postgresql/<major>/main

Substitute the actual PostgreSQL major for <major>. Debian-style clusters may have different names or ports, so use pg_lsclusters and the cluster’s own directory rather than assuming that every server uses the same instance.

The PostGIS administration guidance identifies the cluster environment file as the preferred location for environment settings on Ubuntu and Debian apt installations. Keep cluster-specific environment values there instead of scattering them through unrelated shell profiles. Document which major, cluster, port, and database each setting belongs to, especially when multiple clusters coexist.

Make operational documentation explicit

A useful runbook entry includes:

  • The VPS distribution release codename and architecture.
  • The apt source used: distribution repositories or PGDG.
  • The PostgreSQL major and cluster name.
  • The listening port.
  • The database in which postgis is enabled.
  • Any optional extensions enabled.
  • The output date and result of postgis_full_version().

This information prevents an upgrade or incident response from targeting a similarly named but different cluster.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Managed PostgreSQL: install less, enable carefully

Managed services often package PostgreSQL extensions in advance. Check the provider’s extension list and supported PostgreSQL version before attempting any server-side installation. If PostGIS is listed, connect to the target database with the service’s superuser-equivalent role and run:

CREATE EXTENSION postgis;

Some providers restrict extension creation to a special administrative role. A normal application role may be able to create tables but not extensions, so use the provider’s documented privileged account. The same database-local rule applies: enabling PostGIS in one managed database does not enable it in another.

Troubleshoot installation and connection errors

Symptom Likely cause What to do
extension "postgis" is not available The PostGIS package for the running PostgreSQL major is missing, or you connected to a different cluster. Run pg_lsclusters, compare its major with postgresql-<major>-postgis-3, install the matching package, and rerun the availability query.
CREATE EXTENSION reports a permission error The connected role lacks extension-creation privileges, or the managed provider restricts the operation. Reconnect with a PostgreSQL superuser or the provider’s approved privileged role, then run the command in the target database.
The command succeeds, but the application cannot find PostGIS The extension was created in the maintenance database or another cluster, not the application database. Connect explicitly to the application database and port reported by pg_lsclusters; run SELECT postgis_full_version(); there.
Several clusters appear in pg_lsclusters Debian-style packages allow multiple PostgreSQL majors or cluster names on one VPS. Choose the intended major and port, then use explicit connection parameters for package checks, migrations, and application settings.
The installed package major differs from the running major For example, an 18 extension package was installed while the active cluster is 16. Install postgresql-16-postgis-3 for the active cluster, or deliberately start and configure the 18 cluster if that is the migration target.
PGDG packages cannot be found The repository codename, architecture, signing-key setup, or apt metadata is incorrect. Verify the VPS release codename and architecture, correct the PGDG source, and run sudo apt update before searching again.
PostGIS works on one database but not another Extensions are enabled per database. Connect to the second database and run CREATE EXTENSION postgis; with an authorized role.

A reliable mismatch diagnosis

  1. Run pg_lsclusters and write down the active major, cluster, status, and port.
  2. Check that the installed server package is postgresql-<that-major> and that the PostGIS package is postgresql-<that-major>-postgis-3.
  3. Connect to the reported port and the intended application database.
  4. Run SELECT * FROM pg_available_extensions WHERE name = 'postgis';.
  5. If no row appears, correct the package or cluster mismatch before retrying CREATE EXTENSION.
  6. If a row appears but creation fails, investigate database privileges or managed-service restrictions.

Post-install checklist

  • Package alignment: PostgreSQL and PostGIS package names use the same major number.
  • Cluster selection: The application’s host, port, major, and cluster match the values shown by pg_lsclusters.
  • Database choice: PostGIS is enabled in a dedicated application database rather than the default postgres maintenance database.
  • Privileges: A superuser or provider-approved role performed extension creation.
  • Optional modules: Raster, topology, and SFCGAL extensions are enabled only when required.
  • Verification: Both postgis_full_version() and the availability query return expected results in the target database.
  • Documentation: The repository choice, package major, cluster port, database name, optional modules, and verification output are recorded.

With those checks complete, PostGIS is installed at the server level, enabled at the database level, and tied to the PostgreSQL cluster your application actually uses. Future package upgrades should preserve the same discipline: identify the target major and cluster first, then install or migrate the matching extension package and verify the database again.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Database administrationDebianGISLinux VPSPostGISPostgreSQLUbuntu

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.