Installation of Apache age and PostgreSQL from source in linux part 1
Tags: postgres, database, c, ubuntu
Published: 2023-02-02 05:57:43

Apache age is a PostgreSQL extension that can plot graphs for your relational databases.

The article follows the installation of Postgres and the installation and configuration of apache age with PostgreSQL. 

## Prerequisite:
Ubuntu must be installed in the Virtual Machine or dual boot alongside windows.
You should have ample space in your software.
You should have already installed git. If not you can take help from here "[Install Git](https://github.com/git-guides/install-git)".

I have used ubuntu on a virtual machine. Below is a step-by-step guide for installing age on Linux from the source.

## Installing dependencies:
First, we are going to install age
For that make a new directory and a sub-directory:

```
mkdir age_installation
cd age_installation
mkdir pg
cd pg
```
Download some important libraries by using the below commands before starting the process of installation of Apache Age. Since we are specifically using Linux to install the apache age, we will be using the below commands. 

Remember below commands might vary according to the operating systems.

`sudo apt-get install build-essential libreadline-dev zlib1g-dev flex bison`

# Installation of PostgreSQL from Source:
First, we will install PostgreSQL from source. We need an age compatible version of PostgreSQL. For now, age only supports Postgres 11 and 12.

You can also take help from the following link:
https://www.postgresql.org/docs/current/install-procedure.html

Download the files in the folder age-installation/pg

```
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
```
 
The command will download and extract the tar files for Linux users from Source in the working directory.
Installing PG:
Now we will move toward installing PG 


```
cd postgresql-11.18

# configure by setting flags
./configure --enable-debug --enable-cassert --prefix=$(path) CFLAGS="-ggdb -Og -fno-omit-frame-pointer"

# now install
make install

# go back
cd ../../
```

In the above command, the prefix flag will contain the path where you would like to install the PSQL. Replace your path with the path in the parenthesis.

# AGE:
## Downloading:
Download the age from the GitHub repository. i.e. clone it in the age_installation directory.

`git clone https://github.com/apache/age.git`

## Installing:
Configure age with PostgreSQL.

```
cd age/
sudo make PG_CONFIG=/home/talhastinyasylum/Desktop/age_installation/pg/postgresql-11.18/bin/pg_config install
make PG_CONFIG=/home/talhastinyasylum/Desktop/age_installation/pg/postgresql-8/bin/pg_config installcheck
```

In the above commands, PG_CONFIG requires the path to the pg_config file. The second command will check whether the installation was successful or not.

At the end of the check command, you will receive a message saying all tests passed.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5lo3lp7sy875pmp6o0l5.png)

You can check the part 2 of this article testing of PostgreSQL and Apache-age here [part 2](https://dev.to/talhahahae/initialization-and-creating-a-database-for-testing-the-installation-of-postgres-and-age-part-2-118l).

## References:
You can take help from following links they helped me in installing as well:
1. https://github.com/git-guides/install-git
2. https://age.apache.org/age-manual/master/intro/setup.html
3. https://www.postgresql.org/docs/current/install-procedure.html