Community Blog GISPortal Deployment on Alibaba Cloud Ubuntu 16.04 ECS Instance

GISPortal Deployment on Alibaba Cloud Ubuntu 16.04 ECS Instance

In this tutorial we are going to learn how to deploy GISPortal on Alibaba Cloud Ubuntu 16.04 ECS instance.

By Grace Amondi, Alibaba Cloud Community Blog author

GISPortal is a web-based visualisation and analysis tool for examining geospatial data that is available via Web Map Service (WMS) and Web Coverage Service (WCS).

In this tutorial we are going to learn how to deploy GISPortal on Alibaba Cloud Ubuntu 16.04 Elastic Compute Service (ECS) Instance.


For you to successfully complete this tutorial. you will need to have:

  1. A valid Alibaba Cloud account. If you don't have one already, sign up to the Alibaba Cloud Free Trial.
  2. An ECS instance running Ubuntu 16.04. You can select your preferred region and configurations; this will not affect the outcome of the server setup.
  3. A root password for your server.
  4. Stable Internet connection

Step 1. Clone Repository

First we need to clone the repository, and pull in the submodules:

$ git clone https://github.com/pmlrsg/GISportal.git GISportal
$ cd GISportal
$ git submodule init
$ git submodule update

Step 2. Install Dependencies

Before installing dependencies install yum:

$ sudo apt-get update
$ sudo apt-get install yum

Next install the required dependencies:

yum install nodejs  npm  redis  ruby  gdal  libjpeg-turbo  freetype-devel  libpng-devel  hdf5-devel  \
    netcdf-devel  python-devel  python-pip  python-pillow-devel  python-requests  python-pandas  python-jinja2

NB: Depending on your host OS and how up to date your package manager sources are you may need to update your version of numpy. For example, Centos7 currently has version 1.7.1, and Fedora 21 offers 1.8.2, however, there was a change to the way that masked arrays are handled that was introduced in version 1.8.3. You can check which version you have by running the following in Python:

import numpy

This will give you the version number and the installation location. If you have version number < 1.8.3 you will need to delete the folder where it is installed and install via pip which has a more recent version:

$ pip install numpy

We also need to install all the required libraries. This can be done in a few ways, the easiest using pip. This will probably need sudo permissions.

$ pip install bokeh owslib shapely netCDF4

Step 3. Build JavaScript/CSS

Before building we need to install ruby. Use the following commands:

#Install RVM:
$ \curl -sSL https://get.rvm.io | bash
$ source /home/<user>/.rvm/scripts/rvm

check RVM version:

$ rvm -v

Install Ruby:

$ rvm install 2.5.3
$ rvm use 2.5.3

check Ruby Version

$ ruby -v

Install rails:

$ gem install rails

Install sass

$ gem install sass

For production, JavaScript and CSS should be minifed; the application is configured to offer compressed files unless you tell it to use dev mode. The build mechanism uses Grunt, which first needs to be installed.

Make sure you have Grunt CLI tools

$ npm install -g grunt-cli

Install the Node.js application modules

$ npm install

To build in production mode; this uses minified javascript and CSS

$ grunt

To build in development mode; this uses uncompressed javascript and CSS that can easily be debugged

$ grunt dev

Step 4: Start Redis

If Redis is not installed use the following commands to install it:

$ sudo apt-get update
$ sudo apt-get install redis-server
$ sudo systemctl enable redis-server.service

and then configure Redis:

$ sudo nano /etc/redis/redis.conf

Update the following values in Redis configuration file according to your requirement. You can increase max memory limit as per available on your server.

maxmemory 256mb
maxmemory-policy allkeys-lru

The above configuration tells Redis to remove any key using the LRU algorithm when the max memory of 256mb is reached. Save the configuration file and restart the Redis service:

sudo systemctl restart redis-server.service

Step 5. Run the Application

Run the application. At this point you should have everything you need to start the application

node app.js

You can check the application is running by going to http://<your-ip-address>:6789/ This will give you basic functionality and the ability to add new WMS layers, but if you want to use the application's collaboration features and/or allow users to upload and save geometry files you will need to setup a configuration file.

Step 6. Creating a Configuration File

The application configuration files are created in config and the easiest way to create one is to use the install script; run:

$ ./install.sh

and following the prompts to create a config file. The resulting config file will be created in config/site_settings//config.js - you should keep a backup of this file. Have a look in config_examples/config.js for additional optional configuration options that can be used to change the behviour of your version.

Step 7. On-going maintenance

During normal use of the application users can upload shape files, CSV files and various geometry files to identify their region of interest. Eventually, these are stored in /config/site_settings//user_ but whilst they are being uploaded and converted they are stored in uploads. If the conversion to GeoJSON fails for any reason then the uploaded file is not deleted; you may want to periodcally delete everything from this folder.

If a user requests a plot the resulting plot files are stored in html/plots; this folder can grow to be very large and you may want to periodically delete things from this directory too. During the plot creation a netCDF file is created in /tmp to holde the data for the requested area; these should be deleted regularly too.

You could add a crontab entry to cover each of these tasks:

0 2 find /path/to/GISporal/uploads/ -mtime +1 exec rm -rf {} ; 0 2 find /path/to/GISporal/html/plots -mtime +1 exec rm -rf {} ; 0 2 find /tmp -name ".nc" -mtime +1 exec rm -rf {} ;

Additional Indicator Information

To give users more information, you can set up some markdown files that can be shown on indicators.

To do this you need to create a markdown folder inside the domain level site_settings folder. Inside this folder you should create a folder for each of the layer tags that you want to describe further. Finally fill each tag folder with markdown files in the format: tag_value.md where tag_value is the lowercase value of the tag.

nginx Configuration

The collaboration features of the GISportal use websockets to communicate between server and browser. nginx offers really good support for websockets so this is the preferred and recommended web server software; other web servers may work but not fully.

An example nginx configuration would look like this:

server {
    listen *:80;
    location  /. { ## Disable .htaccess and other hidden files
        return 404;
    location / {
        try_files @uri @location_node;
    location @location_node {
        proxy_pass http://localhost:6789;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_redirect     off;
        proxy_set_header   Host $host;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Host $server_name;


There is a Dockerfile that can be used to build a Docker image provided with this repository. See the [docker-readme.md] file for full details of how to do this.

Alternatively, you can use the pre-built image that is available to download from the Docker Hub

$ docker pull pmlrsg/gisportal


Enabling basic GA

Go to config/config.js and set gisportal.config.analytics.active to true and gisportal.config.analytics.UATrackingId to the tracking code of the project. Basic tracking is now enabled.

Setting up Custom Definitions

For a deeper level of tracking custom definitions needs to be setup. For this you need to go into the google analytics admin and select Custom Definitions under the property column.

Custom Dimensions

Start by clicking Custom Dimensions and creating a new custom dimension labeled Indicator Name.

Proceed to make this list IN THIS ORDER:

Indicator Name
Indicator ID
Layer Style
Graph type
Click Location

Custom Metrics

In the left hand panel select Custom Metrics and again make the following in the same order:

  • Used in graph
  • Used in layer

If you had no previous metrics or dimensions installed and you added them in the listed order analytics is now setup.

Follow this section only if you already had custom metrics made or did not make them in that order:

Each custom definition has a unique index.cm0-9 for Custom Metrics and cd0-9for Custom Dimensions.

Indexes can not be changed. The current config file was expecting the definition names to be next to certain indexes.

Go over each custom definition key in the config file and change it the one in your analytics account.

Currently mapped names:


#cd1 Indicator Name
--- ---
#cd2 Indicator ID
#cd3 Region
#cd4 Interval
#cd5 Elevation
#cd6 Layer Style
#cd7 Graph type
#cd8 Confidence
#cd9 Year
#cd10 Click Location
#cd11 Indicator Provider


#cm1 Used in graph
#cm2  Used in layer

A list of example instances of the GISportal software is available at http://pmlrsg.github.io/GISportal

0 0 0
Share on

Alibaba Clouder

2,600 posts | 750 followers

You may also like