# Gisgraphy installation guide 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 havn't Postgres, Postgis and java installed, you must install it first. a tutorial is provided here for linux and here for windows

## Download a Gisgraphy distribution

- Fisrt you have to download a distribution here. Download a tar.gz file, if you are on Linux or download a zip file, if you are on windows.
- Then extract it : tar xvf YOURFILE if you're on linux or double click on the file if your on Windows

## Initialize The database

Here are the command to run to install and init the Gisgraphy database

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

    #create language
    createlang -U YOURUSER -h YOURIP plpgsql gisgraphy

    #create postgis function
    psql -U YOURUSER -h YOURIP -d gisgraphy -f /usr/share/postgresql-YOURPOSTGRESVERSION-postgis/lwpostgis.sql
    psql -U YOURUSER -h YOURIP -d gisgraphy -f /usr/share/postgresql-YOURPOSTGRESVERSION-postgis/spatial_ref_sys.sql

    #create tables;
    psql -UYOURUSER -f /path/to/file/create_tables.txt

    #create spatial indexes
     psql -U YOURUSER -h YOURIP -f createGISTIndex.sql

Where YOURUSER is a postgresql user with admin rights,YOURIP is the ip adress of your server(127.0.0.1 in most case) and YOURPOSTGRESVERSION is your postgres version (8.3 in this tutorial)
Then insert users (...for the admin interface,... you don't have to log to use gisgraphy webservices) in the database. A script called insert-users.sql is provided with two default users: one with admin rights and one with simple rights.
psql -UYOURPOSTGRESQLUSER -f /path/to/file/insert_users.sql
It is HIGHLY recommended to modify them for security : once gisgraphy is installed :

- loging as 'admin' with password 'admin'
- Go to the http://localhost:8080//admin/users.htmlpage
- Change the admin and user password

## Edit database and Gisgraphy settings

Go into the directory you've extract the gisgraphy distribution, Then edit the database settings in the jdbc.properties file in the directory 'webapps/ROOT/WEB-INF/classes' of the Gisgraphy distribution.
You can edit the configuration (import, and so on) in the env.properties file in directory 'webapps/ROOT/WEB-INF/classes' of the Gisgraphy distribution (for more information see options documentation).
that's all, you can now start gisgraphy

## Start Gisgraphy

- Open a command line (Start/run and type 'cmd')
- Change the current directory to the folder where you've unzip the files
- Type "`java -Xms512M -Xmx512M -jar start.jar` "

Important : You must type the command line in the directory where you've extract the Gisgraphy files.
The directory where you type the command to start your servlet container (e.g : `java -jar start.jar` for Jetty or `startup.sh/startup.bat` for Tomcat) determines the directory Where The full text data will be stored : the data will be stored in the `$Current_Working_directory/solr` Directory. In other words :

- If you are in directory 'foo' and you type : "`java -jar ./directory/where/Gisgraphy/is/Extracted/start.jar`" The data will be stored in `foo/solr`, because you are in the 'foo' directory
- If you are in directory 'foo' and you type : "`cd directroy/where/gisgraphy/is/extracted/start.jar`" and then "`java -jar start.jar`", the Data will be stored in the 'extracted' directory, because you are in the 'extracted' directory.

This is the same thing for Tomcat or any servlet Container (Resin, ...) due to solr. More...
To avoid OutOfMemoryError : you must launch Gisgraphy with a minimum memory of 512M. To do this : set your CATALINA_OPTS to `-Xms512M -Xmx512M` (e.g : add this CATALINA_OPTS=-Xms512M -Xmx512M to the .bashrc file in your home directory)

## See if it works

Open a browser and go to http://localhost:8080/mainMenu.html. you should see the admin page and then go to http://localhost:8080/ you should see a Gisgraphy page

## And now...

Now, You can :

- Import data
- Improve security
- Improve performances
- See the FAQ
- Use the forum