# Installation

## Download

&pgsphere; is not the part of the &postgresql; software. You can download the latest release from the &pgsphere; Releases page. The source code can also be downloaded by cloning the repository with the appropriate release tag. The master branch is intended for development use and may contain the code in a transitional state. It is not recommended for use in production.

## Install

It is assumed that &postgresql; is already installed. Depending on the system configuration, superuser (root) access rights may be required to complete the installation.

The installation script uses &pg_config; utility. Make sure that the environment variable PATH includes path to &pg_config; utility. The path to &pg_config; can be also specified in make command:

    shell> make PG_CONFIG=/path/to/pgconfig ...

Unpack the downloaded archive and enter the directory:

    shell> tar -xzf path/to/pgsphere-X.X.X.tgz
    shell> cd pgsphere-X.X.X

Compile the code. By default, &pgsphere; is compiled with &healpix; support.

    shell> make

or compile without &healpix; support:

    shell> make USE_HEALPIX=0

Run regression tests optionally. If &pgsphere; was compiled without &healpix; support, USE_HEALPIX=0 should be specified in make command line.

    shell> make test

Install &pgsphere; files to the installation directories. The installation directories are defined by &pg_config; utility. Superuser (root) access rights may be required. If &pgsphere; was compiled without &healpix; support, USE_HEALPIX=0 should be added after make.

    shell> make install

## Configure Extension

We assume you have already created a database userdb, where userdb is the name of any database. Assume that the name of &postgresql;'s superuser is `postgres`.

    shell> psql -U postgres -c 'CREATE EXTENSION pg_sphere' userdb

It may be necessary to give more `psql` options, like port or host name, depending on your system configuration. Please, take a look at the psql user manual for details. The psql user manual for the latest &postgresql; version can be found at &postgresql; site .

To get the version of installed &pgsphere; software:

    pgsql> SELECT pg_sphere_version();