DEV Community

Chidera Stella Onumajuru
Chidera Stella Onumajuru

Posted on • Edited on

Step-by-Step guide on Installing WSL and PostgreSQL from source code on Windows.

PostgreSQL is a powerful open-source relational database management system (DBMS) which is extensible. Apache AGE is a Postgres extension that enables one to make hybrid queries. To Install AGE, we must install PostgreSQL version 11 or 12 from source code, as they are the only AGE compatible version as at the time of this writing. In this post, I am going to show you a clear guide on how to install PostgreSQL from source code. This is a continuation of my previous post about AGE here.

WSL Installation.
On your Windows machine, do the following;

  1. Open settings > apps> > optional features > more windows features > enable WSL.

  2. This would prompt you to reboot your system.

  3. Visit the Microsoft store, install Ubuntu and follow the prompts.

PostgreSQL Installation guide.

  • Create a directory where PostgreSQL will be downloaded in.

    mkdir postgres-age && cd postgres-age
    mkdir postgres && cd postgres
    
  • Download the required dependencies.

    sudo apt-get install build-essential libreadline-dev zlib1g- 
    dev flex bison
    
  • Download the build tool for multiple PostgreSQL versions using the command below.

    sudo apt install postgresql-server-dev-all
    
  • Or this command below.

    sudo apt install postgresql-common
    
  • Download PostgreSQL. This command does the following;

    1. Downloads PostgreSQL from source code.
    2. Extract the file contents.
    3. Removes the download archive.
    wget https://ftp.postgresql.org/pub/source/v11.18/postgresql- 
    11.18.tar.gz && tar -xvf postgresql-11.18.tar.gz && rm -f 
    postgresql-11.18.tar.gz
    
  • Enter into the newly downloaded postgresql-11.18 directory.

    cd postgresql-11.18
    
  • Run the build configuration and enable debug flags.

    ./configure --enable-debug --enable-cassert --prefix=$(pwd) 
    CFLAGS="-ggdb -Og -fno-omit-frame-pointer"
    
  • Install PostgreSQL.

    make install
    

With this, PostgreSQL is successfully installed. To confirm your download, create a database cluster using the command below. A database cluster is a collection of databases that are managed by a single instance of a running database server.

```
bin/initdb demo 
```
Enter fullscreen mode Exit fullscreen mode
  • Start the server.

    bin/pg_ctl -D demo -l logfile start
    
  • Stop the server.

    bin/pg_ctl -D demo -l logfile stop
    

Read more about AGE here

Contribute to Apache Age.
https://age.apache.org/
https://github.com/apache/age

Top comments (2)

Collapse
 
muhammadzeeshan03 profile image
Muhammad Zeeshan

Hi, i was following this blog and found a mistake in the command.
sudo apt install postgresql-server-dev-all
here is the error message.

Error Image

Here is the correct command that worked for me.
sudo apt install postgresql-common

Correction

Collapse
 
chidera profile image
Chidera Stella Onumajuru

Hello, thanks for your feedback, the previous command was what I used actually just like the error message suggests it might be obsolete, though I could not see any information when I googled about it, I will be adding this new command to the blog post,Thanks again.