Gisgraphy is a free open-source geocoding and webservices solution. It is a greate alternative to google’s geocoding API service, which has many limitations on usage. 

Gisgraphy can provide the best relevance of geocoding, since it combines both geonames and openstreetmap dataset. In fact, besides geocoding, Gisgraphy can be used for reverse geocoding, street search, find nearby, fulltext search, and address parser. I’d recommend you go to their demo site and try it!

In this post, I’ll show you step by step on how to install Gisgraphy 3.0 on your local machine with Ubuntu 12.04. I’ll use: Java JDK 7, PostgreSQL 9.1 and Postgis 1.5. (Note that Gisgraphy 3.0 does NOT support Postgis 2.0). The official site did provide a installation guide, but it is sort of out of date.

1. Install Java SDK

1.1 Install oracle-jdk7

Run the following commands in your terminal to install jdk7:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-jdk7-installer

Check to see if you have successfully installed java:

java -version # should get java version "1.7.0_21" or something like that
javac -version # should get javac 1.7.0_21 or something like that

1.2 Set up Java environment

Open .bashrc file using vim or any other text editor:

sudo vim .bashrc

Add the following line at the end of file:

export JAVA_HOME=/usr/lib/jvm/java-7-oracle

Reload the settings by running:

source ~/.bashrc

Now you can check to see if the setting has applied by running

echo $JAVA_HOME # should return /usr/lib/jvm/java-7-oracle

2. Install PostgreSQL and Postgis

2.1 Install postgreSQL and postgis

Run the following command to install postgresql:

sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update
sudo apt-get install libpq-dev
sudo apt-get install postgresql
sudo apt-get install postgresql-9.1-postgis

Check if it is successfully installed:

psql -V

2.2 Create password for user: postgres

Enter postgres console with username postgres:

sudo -u postgres psql

Inside of postgres, run the following command to change password:

ALTER USER postgres PASSWORD 'yourpassword';
\q # quite postgres console

2.3 Create database, language and postgis function

All the following command will use the user postgres with the password you just created.

# create the database
psql -U postgres -h -c "CREATE DATABASE gisgraphy ENCODING = 'UTF8';"

#create language
createlang -U postgres -h plpgsql gisgraphy

#create postgis function
psql -U postgres -h -d gisgraphy -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql

psql -U postgres -h -d gisgraphy -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql

Restart the server:

sudo /etc/init.d/postgresql restart

3. Update Linux File Limit

To avoid message like Too many open files when solr opens a large number of files, you must increase maximum number of files limit.

Open your terminal, and edit limits.conf file:

sudo vim /etc/security/limits.conf

Add the following 2 lines to the file, note that do not miss the * mark:

* hard nofile 20000
* soft nofile 20000

That’s it, now everything is set up. In the next step, we are going to install Gisgraphy server.

4. Insatll Gisgraphy

4.1 Download Gisgraphy

Download Gisgraphy from here.

Open your terminal, go to the directory that contains the downloaded file, and unzip it:

mv gisgraphy-3.0-beta2 gisgraphy

4.2 Initialize tables

Now we need to create tables:

cd gisgraphy/
psql -Upostgres -d gisgraphy -h -f ./sql/create_tables.sql

Then, add default users:

psql -Upostgres -d gisgraphy -h -f ./sql/insert_users.sql

The above command creates two default users: one is admin with password admin, the other one is user.

4.3 Settings

Go to gisgraphy directory, and open file:

vim webapps/ROOT/WEB-INF/classes/

Fill the jdbc.password field with your password:


Note that do not leave any space between =

Lastly, we can set up environment variables in file, which is also under webapps/ROOT/WEB-INF/classes/ directory.

There are 3 parameters that I think are worth to check out:

Since I’m only interested about data in USA, I can set geonamesfilesToDownload and openstreetmapfilesToDownload to only download data for US. This will save a lot of space. What’s more, the googleMapAPIKey can be used to display map in the demo server. You can register and get the API key from Google’s api console.

For all the other options, check out the document.

4.4 Run the server

Ok, now it’s time to run the server. Change the file mode to executable, and then run it:

chmod +x

Now, you should be able to visit http://localhost:8080/mainMenu.html page in your browser. Next thing is go through the wizard in the main page and download the dataset. Yeah!