# Environement setup for Windows

Before install and launch Gisgraphy, you must setup java, postgres, and postgis. it is not, properly speaking, the installation of gisgraphy, and if you already have postgres, postgis and java installed(you needs JVM >= 1.5), you can go directly to the gisgraphy installation guide

## Install Java

You can find a good tutorial on this page : http://java.sun.com/javase/6/webnotes/install/index.html

## Install postgresql and postgis

If you already have Postgresql installed, you can skip this section

### Install postgresql

This section will guide you step by step to install Postgresql on Windows.
before install Postgresql 8.3 we have to download it. You can download it on the mirror page once you've download, you've got a file named postgresql-8.3.0-1.zip. you have to extract it by double clicking on it you will have the following list of files :
To start the installation of PostgreSQL 8.3 , double click on 'SETUP.bat' ou 'postgresql-8.3.msi'
If you've already have a 8.2 PostgreSQL version, don't run upgrade.bat. this script is only present to upgrade RC (aka Release client and Beta version).
Exit all Windows programs before installation and click "Next":
You'll have to choose your language and click "Start". On the next screen, read the installation notes if you want (not necessary ;) ) and click "Next":
the next screen detailled the installation options and module. Let the default options and click "Next"
On Windows, Posgresql is seen as a service. so it need a user account on the machine. The default user created is named 'postgres'. Enter the password twice and click "Next". The password you give will not be the password of the PostgreSQL user 'postgres'.
now you have to choose the password for the the PostgreSQL user 'postgres'. it is the database user with all rights. For this reason you have to remember the password because you'll need it to log in and create the database and tables.
It is strongly recommended to put an other password than the windows account one. choose 'mdppostgres' if you want to use the default password define in Gisgraphy.
Click on "Accept connections on all adresses, not just localhost" (recommended, but not necessary if you will only use postgres on the computer) choose your locale and choose 'UTF-8' for encoding (server)!! click "next".
A message will prompt. it tells you that, due to the fact that you've checked Accept connections on all adresses, not just localhost" : the server will be reachable from other computers. .
Some procedural languages can be installed now or later, by default 'PL/pgsql' is checked. that mean that it will be install.
Keep the 'PL/pgsql' checked (it will be used by postgis) and click "Next".
Now you have to choose the contrib modules. Keep 'Adminpack' and 'Debugger' and click "Next".
That's all we need, PostgreSQL is ready to be installed. Click "Next".
You can see the installation progress.
Here we are.PostgreSQL is installed !
Subscribe to pgsql-announce if you want to be informed of update and bug corrections.
Keep 'launch stack builder on exit' checked and click on "finish"
WE will install PostGIS.

### Install postgis

Select your database server and click on "Next"
Check 'postgis 1.3.3' and click "Next".
Select a connection to download PostGIS and click "Next"
Keep The default destination folder where the installation files will be downloaded.
we need to download the PostGIS installation files, click "Next" : the files will be downloaded.
Then every thing is ready to launch the postgis install.click "Next" to begin the installation
Read the license and click 'I Agree' if it is the case ;)
unchecked 'create spatial database' (we don't need) and click "Next"
keep the default destination folder "C:\Program Files\PostgreSQL\8.3\" and click "Next"
We need to enter the postgresql user password to initialize PostGIS (not the computer account one), keep the default port, and click "Next".
PostGIS will be installed :
Now postgis is installed ! Click on "Close" :
if you see this screen, that mean that you've install postres and postgis
Tips : Install PGAdmin. It will be more user friendly than command line.
In order to know if Postgis is correctly install, open a PostgreSQL connection (start/Programs/'PostgreSQL 8.3'/'psql to postgres') or PgAdmin and type :

- `select version ();` or `SHOW server_version;`. It will give you the PostgreSQL version
- `select postgis_full_version () ;` It will give you the Postgis version

## Create the database

Here are the command to create the Gisgraphy database
Important : You have to deconnect all the users from the Template_postgis database if you want to create the gisgraphy database from the Template_postgis

    # create the database
    psql -U YOURUSER  -h YOURIP -c  "CREATE DATABASE gisgraphy WITH TEMPLATE = Template_postgis ENCODING = 'UTF8';"

## And now...

Now that you environement is setup, you can go to the Gisgraphy installation guide