Installation of Apache age and PostgreSQL from source in Mac part 1
Published: 2023-02-12 08:58:34

The following steps outline the process of installing Apache AGE with PostgreSQL:

Install PostgreSQL - This is the first step in setting up Apache AGE. You need to have a PostgreSQL database installed to start working with Apache AGE.
Install Apache AGE - Once you have PostgreSQL installed, you can install Apache AGE by following the instructions provided in the official documentation.

Configure Apache AGE - After you have installed Apache AGE, you will need to configure it to work with your PostgreSQL database. This typically involves modifying the configuration files to specify the database connection details and other settings.
Plot your relational databases - Once you have completed the installation and configuration, you can start plotting your relational databases using Apache AGE.
Note: The exact steps for installing and configuring Apache AGE may vary based on your operating system and the version of PostgreSQL you are using. Be sure to consult the official documentation for specific instructions and guidance. 



## Prerequisite:

1:- To enter the bash shell, follow these steps:

Open the terminal or command line interface on your system.
Type "bash" and press enter.
You will now be in the bash shell.
You can also use the "bash" command as an option when opening a terminal window on some systems. For example, you can right-click on the desktop and select "Open Terminal" and then specify "bash" as the shell to use.





2:-Before proceeding, it is assumed that you have already installed Git. If not, you can follow these steps to install it:

Go to the official Git website: https://git-scm.com/downloads
Download the appropriate version of Git for your operating system.
Follow the installation instructions for your operating system to complete the installation process.
If you need additional help with the installation process, you can refer to the official Git documentation or seek guidance from other resources.


## Installing dependencies:
To install dependencies:

Create a new directory.
Within that directory, create a sub-directory.
In the sub-directory, we will install Apache Age.

```
mkdir age_installation
cd age_installation
mkdir pg
cd pg
```

To download important libraries for installing Apache Age on a Mac, you can follow the steps below:

1:-Install Homebrew:
Homebrew is a popular package manager for macOS. It simplifies the installation process of libraries and tools on a Mac.
If you don't already have Homebrew installed on your Mac, you can install it by running the following command in your terminal:

```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

```


Follow the instructions in the terminal to complete the installation of Homebrew.


2:-Install libraries:
After installing Homebrew, run the following command in your terminal to install the required libraries for Apache Age:

```
brew install build-essential libreadline zlib flex bison

```
This command will install the libraries: build-essential, libreadline, zlib, flex, and bison.
That's it! You now have the required libraries installed on your Mac for Apache Age.

To Install dependencies individually:-
To install the dependencies required for Apache Age on Mac, you can use Homebrew to install the required libraries individually.

Here is how you can install the dependencies:

```
brew install libreadline
brew install zlib
brew install flex
brew install bison

```


## Installation of PostgreSQL from Source:
nstallation of PostgreSQL 12 on Mac:
To install PostgreSQL 12 on Mac, we will first download the files using the terminal. To do this, use the following command:

```
curl -O https://ftp.postgresql.org/pub/source/v12.0/postgresql-12.0.tar.gz && tar -xvf postgresql-12.0.tar.gz && rm -f postgresql-12.0.tar.gz

```
Once the files are downloaded, follow the installation procedure as mentioned in the official documentation at the following link: https://www.postgresql.org/docs/current/install-procedure.html

The command will download and extract the tar files for Mac users from Source in the working directory.
Installing Postgres:
Now we will move toward installing Postgres.

```
cd postgresql-12.0
# configure
./configure
# now install
make install
# go back
cd ../../
```

## AGE:-
Download the age from the GitHub repository. i.e. clone it in the Apache_age.



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

## Installing:
Configure age with PostgreSQL.

```
cd age/
sudo make PG_CONFIG=/Users/moiz/Apache_age/postgres/postgresql-12.0/bin/pg_config install;
make PG_CONFIG=/Users/moiz/Apache_age/postgres/postgresql-12.0/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.



## References:
You can take help from following links they helped me in installing as well:

https://github.com/git-guides/install-git
https://age.apache.org/age-manual/master/intro/setup.html
https://www.postgresql.org/docs/current/install-procedure.html

[Apache-Age:-https://age.apache.org/](https://age.apache.org/)
[GitHub:-(https://github.com/apache/age ](https://github.com/apache/age)