{"id":13293,"date":"2023-10-02T03:18:49","date_gmt":"2023-10-02T07:18:49","guid":{"rendered":"http:\/\/local.brightwhiz\/?p=13293"},"modified":"2023-10-02T03:32:33","modified_gmt":"2023-10-02T07:32:33","slug":"how-to-install-the-latest-postgis-on-ubuntu-22-04","status":"publish","type":"post","link":"http:\/\/local.brightwhiz\/how-to-install-the-latest-postgis-on-ubuntu-22-04\/","title":{"rendered":"How to Install the Latest PostGIS on Ubuntu 22.04"},"content":{"rendered":"\n
PostGIS is a powerful open-source spatial database extension for PostgreSQL<\/a> that allows you to store, query, and manipulate geographic and geometric data. If you’re using Ubuntu 22.04 and need to set up the latest version of PostGIS for your spatial data needs, you’re in the right place. In this guide, we’ll walk you through the step-by-step process to install the latest PostGIS on your Ubuntu 22.04 system.<\/p>\n\n\n\n Before you start the installation process, make sure you have the following prerequisites in place:<\/p>\n\n\n\n It’s always a good practice to ensure your system is up to date before installing any new software. Open a terminal and run the following commands:<\/p>\n\n\n\n This will update the package lists and upgrade any existing packages to their latest versions.<\/p>\n\n\n\n PostGIS is an extension for PostgreSQL, so you’ll need to have PostgreSQL installed. If it’s not already on your system, you can install it with the following command:<\/p>\n\n\n\n Now that PostgreSQL is installed, you can proceed to install PostGIS. Ubuntu 22.04’s default repositories may not always have the latest version of PostGIS, but you can use the PostgreSQL apt repository to get the most recent version. Here’s how:<\/p>\n\n\n\n Now, update the package list again and install PostGIS:<\/p>\n\n\n\n Replace Once PostGIS is installed, you can create a new PostgreSQL database and enable PostGIS in it. Replace To ensure that PostGIS is installed correctly and functioning, you can connect to your PostGIS-enabled database and run a simple query:<\/p>\n\n\n\n Inside the PostgreSQL prompt, run the following query:<\/p>\n\n\n\n This query should return the version of PostGIS you installed, confirming that the installation was successful.<\/p>\n\n\n\n You’ve now successfully installed the latest version of PostGIS on your Ubuntu 22.04 system. You can use this powerful spatial extension to work with geographic and geometric data in your PostgreSQL databases. If you encounter any issues or need further assistance, consult the PostGIS documentation<\/a> or seek help from the PostGIS community to make the most of this valuable tool for spatial data management.<\/p>\n","protected":false},"excerpt":{"rendered":" PostGIS is a powerful open-source spatial database extension for PostgreSQL that allows you to store, query, and manipulate geographic and geometric data. If you’re using Ubuntu 22.04 and need to…<\/p>\n","protected":false},"author":1,"featured_media":13301,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,23,9,16,18],"tags":[1266,433,449,955,531,544,591,598,635],"yoast_head":"\nPrerequisites:<\/h3>\n\n\n\n
\n
Step 1: Update Your System<\/h3>\n\n\n\n
$ sudo apt update\n$ sudo apt upgrade<\/code><\/pre>\n\n\n\n
Step 2: Install PostgreSQL<\/h3>\n\n\n\n
$ sudo apt install postgresql postgresql-contrib<\/code><\/pre>\n\n\n\n
Step 3: Install PostGIS<\/h3>\n\n\n\n
3.1: Add the PostgreSQL Repository<\/h4>\n\n\n\n
$ sudo sh -c 'echo "deb http:\/\/apt.postgresql.org\/pub\/repos\/apt $(lsb_release -cs)-pgdg main" > \/etc\/apt\/sources.list.d\/pgdg.list'\n<\/code><\/pre>\n\n\n\n
3.2: Import the Repository Signing Key<\/h4>\n\n\n\n
$ wget --quiet -O - https:\/\/www.postgresql.org\/media\/keys\/ACCC4CF8.asc | sudo apt-key add -\n<\/code><\/pre>\n\n\n\n
3.3: Install PostGIS<\/h4>\n\n\n\n
$ sudo apt update\n$ sudo apt install postgis postgresql-<version>-postgis-<version><\/code><\/pre>\n\n\n\n
<version><\/code> with the specific PostgreSQL and PostGIS versions you want to install. For example, for PostgreSQL 14 and PostGIS 3, use:<\/p>\n\n\n\n
$ sudo apt install postgis postgresql-14-postgis-3\n<\/code><\/pre>\n\n\n\n
Step 4: Create a PostGIS-enabled Database<\/h3>\n\n\n\n
<your_database><\/code> with your desired database name:<\/p>\n\n\n\n
$ sudo -u postgres createdb <your_database>\n$ sudo -u postgres psql -d <your_database> -c "CREATE EXTENSION postgis;"<\/code><\/pre>\n\n\n\n
Step 5: Verify the Installation<\/h3>\n\n\n\n
$ sudo -u postgres psql -d <your_database><\/code><\/pre>\n\n\n\n
SELECT postgis_version();<\/code><\/pre>\n\n\n\n
Conclusion:<\/h3>\n\n\n\n