Gisgraphy is a free opensource geocoding and webservices solution. It is a greate alternative to google’s geocoding API, which has lots of limitation 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, Street search, Find nearby, Fulltext search, Address parser. I’d recommend you go to their demo site and try it!

Here, I’ll show you how to install Gisgraphy 3.0 on your local machine with Ubuntu 12.04 step by step. I’ll use: Java JDK 7, PostgreSQL9.1 and Postgis 1.5 . ( Notice 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 data.

1. Install Java SDK

1.1 Install oracle-jdk7

Run the following commands inside of terminal to install jdk7:

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

You can check if you successfully installed java by running:

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 is effect by running

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

2. Install PostgreSQL9.1 and Postgis 1.5

2.1 Install postgreSQL and postgis

Run the following command to install postgresql:

sudo apt-get install python-software-properties
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 postgresql is successfully installed:

psql -V

2.2 Create password for user: postgres

Enter postgres console with username ‘postgres’:

sudo -u postgres psql

Then, inside of postgres, run the following command to change password of ‘postgres’:

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

After all the settings are done, restart the server by running:

sudo /etc/init.d/postgresql restart

3. Linux file limit settings

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 terminal, and edit limits.conf file using vim:

sudo vim /etc/security/limits.conf

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

* hard nofile 20000
* soft nofile 20000

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

4. Insatll Gisgraphy

4.1 Download Gisgraphy

Download Gisgraphy from here.

Open your terminal, go to your directory where the file is downloaded, and unzip it:


mv gisgraphy-3.0-beta2 gisgraphy

4.2 Initialize tables

After that, we need to create tables:

cd gisgraphy/

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

Then, add default user:

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

The above command will give two default user one is admin with password admin, the other one is user.

4.3 Settings

In order to make the server run, we need to fill the password of postgres in file. Inside of gisgraphy directory:

vim webapps/ROOT/WEB-INF/classes/

Open the file, and fill the jdbc.password field with your password. Notice that do not leave any space after ‘=’


Then it’s pretty much done. Last thing is we can set up environment inside of file, which is also under webapps/ROOT/WEB-INF/classes/ directory.

There are 3 parameters that I think is worth to take a look at it. These are:

For me, I’m only interested about data in USA, so I set geonamesfilesToDownload and openstreetmapfilesToDownload to only download data for US. This will save us a lot of space. What’s more, the googleMapAPIKey can be used to show map in the demo server. You can get it from google’s api console.

All the other settings can be reference from 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.  Next thing is go through the wizard in the main page to download the dataset. Yeah!

2 Thoughts on “Install Gisgraphy on Ubuntu 12.04 from Scratch

  1. Do you know the minimal hardware requeriments for the instalation (data of my country -Argentina- is quite small) ? Thanks!

  2. Hi, I think it does not require that much CPU or memory. But it needs lots of disk space. It provides a very nice GUI where you can select the data of different country. I don’t know how large is the data for Argentina

Leave a Reply

Post Navigation