DEV Community

Bhaskar Sharma
Bhaskar Sharma

Posted on

Installing PostgreSQL & Apache AGE for debugging (Part 1)


This is part 1 of a guide for setting up PostgreSQL and Apache AGE on a Linux (Ubuntu) machine for debugging. After following this blogpost, you'll be able to:

  • Install PostgreSQL from source with debugging flags enabled.

  • Check part 2 to know how to install Apache AGE from source for debugging.

Installing PostgreSQL from source (with debugging flags enabled)

The first step is to download a compatible version of PostgreSQL with the Apache AGE version you will be working with.
At the time of writing this guide, PostgreSQL version 15 can be downloaded as it is compatible with the latest version of Apache AGE.

  • Download the PostgreSQL version 15 source from here download the .tar.gz file.

  • Unpack it using gunzip like
    gzip -d postgresql-15.4.tar.gz

  • Unpack the tarball
    tar -xf postgresql-15.4.tar

  • cd into the folder
    cd ./postgresql-15.4/

  • Before installing PostgreSQL, we need to install some prerequisites (Bison & Flex) which are used both by PostgreSQL and Apache AGE for parsing queries
    sudo apt-get install build-essential libreadline-dev zlib1g-dev flex bison

  • We are ready to install. So, first we configure it with the debugging flags
    ./configure --enable-debug --enable-cassert

  • Then we install it using the make commands
    make all
    sudo make install

  • Now, we have PostgreSQL installed on our system, but we need to tell our system where the binaries are. For that, we'll add the location to our PATH variable.
    export PATH

    To make it permanent, you need to add the export commmand to the end of your your ~/.bash_profile file.

  • Next, let us initialize a database cluster using
    initdb -D $HOME/pgdata

You can replace $HOME/pgdata with a directory of your choice, the -D flag is used to specify a directory.

  • To start the server, we will use pg_ctl command pg_ctl start -D $HOME/pgdata The server should start successfully. To enter PostgreSQL command line you can use psql.

Use \q to quit it, and proceed to next blog post.

Top comments (0)