Install GeoNode application¶
Install required libs¶
Make sure all the needed libraries are installed:
sudo yum install -y git gdal gdal-python geos python-pip python-imaging \
python-virtualenv python-devel gcc-c++ python-psycopg2 libxml2 \
libxml2-devel libxml2-python libxslt libxslt-devel libxslt-python
Create a geonode system user for the application¶
Create the group:
sudo groupadd --system geonode
Create the user:
sudo useradd --system --gid geonode --shell /bin/bash --home /home/geonode --create-home geonode
Create project home somewhere:
sudo mkdir -p /opt/apps/geonode
Give the required permissions to the new user geonode:
sudo chown -R geonode:geonode /opt/apps/geonode/
Install GeoNode¶
As a user geonode install GeoNode sources from official repository:
curl -LO "https://github.com/GeoNode/geonode/archive/2.6.3.zip"
unzip 2.6.3.zip && mv geonode-2.6.3 geonode
Move the sources into project folder:
mv geonode /opt/apps/geonode/
Navigate to sources folder and install required packages:
cd /opt/apps/geonode/geonode
sudo pip install -e . --upgrade --no-cache
Edit settings¶
GeoNode Configuration¶
Now that all applications have been configured we are going to instruct GeoNode on how to connect to PostgreSQL and GeoServer. Also we are going to instruct GeoNode on who is allowed to connect to it.
First navigate to geonode configuration folder:
cd /opt/apps/geonode/geonode/geonode/
Copy the local_settings.py sample file called local_settings.py.sample:
cp local_settings.py.geoserver.sample local_settings.py
Then edit the configuration file:
vim local_settings.py
Add the ALLOWED_HOSTS and PROXY_ALLOWED_HOSTS variables at the top with the following values::
ALLOWED_HOSTS = ['127.0.0.1', 'localhost', '::1']
PROXY_ALLOWED_HOSTS = ("127.0.0.1", 'localhost', '::1', )
Add the POSTGIS_VERSION variable matching your PostGIS version::
POSTGIS_VERSION = (2, 3, 0)
This will instruct GeoNode to listen on connections from your local machine.
Change the value of the SITEURL:
SITEURL = "http://localhost/"
Now configure database access: Uncomment the ENGINE’: ‘django.contrib.gis.db.backends.postgis line and comment the one with empty ENGINE variable. Also set the NAME variable to geonode_data:
DATABASES = {
'default': {
...
},
'datastore' : {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
#'ENGINE': '', # Empty ENGINE name disables,
'NAME': 'geonode_data',
...
}
Then configure GeoServer location: Change the value of the LOCATION and PUBLIC_LOCATION variables as below:
GEOSERVER_LOCATION = os.getenv(
'GEOSERVER_LOCATION', 'http://localhost/geoserver/'
)
GEOSERVER_PUBLIC_LOCATION = os.getenv(
'GEOSERVER_PUBLIC_LOCATION', 'http://localhost/geoserver/'
)
Finally configure GeoServer datastore: Change the value of the DATASTORE variable to the dictionary identifier of database for spatial data as below:
OGC_SERVER = {
'default': {
...
'DATASTORE': 'datastore',
}
The resulting configuration file should look like this::
import os
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
ALLOWED_HOSTS = ['127.0.0.1', 'localhost', '::1']
PROXY_ALLOWED_HOSTS = ("127.0.0.1", 'localhost', '::1', )
POSTGIS_VERSION = (2, 3, 0)
SITEURL = "http://localhost/"
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'geonode',
'USER': 'geonode',
'PASSWORD': 'geonode',
},
# vector datastore for uploads
'datastore' : {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
#'ENGINE': '', # Empty ENGINE name disables
'NAME': 'geonode_data',
'USER' : 'geonode',
'PASSWORD' : 'geonode',
'HOST' : 'localhost',
'PORT' : '5432',
}
}
GEOSERVER_LOCATION = os.getenv(
'GEOSERVER_LOCATION', 'http://localhost/geoserver/'
)
GEOSERVER_PUBLIC_LOCATION = os.getenv(
'GEOSERVER_PUBLIC_LOCATION', 'http://localhost:8001/geoserver/'
)
# OGC (WMS/WFS/WCS) Server Settings
OGC_SERVER = {
'default': {
'BACKEND': 'geonode.geoserver',
'LOCATION': GEOSERVER_LOCATION,
'LOGIN_ENDPOINT': 'j_spring_oauth2_geonode_login',
'LOGOUT_ENDPOINT': 'j_spring_oauth2_geonode_logout',
# PUBLIC_LOCATION needs to be kept like this because in dev mode
# the proxy won't work and the integration tests will fail
# the entire block has to be overridden in the local_settings
'PUBLIC_LOCATION': GEOSERVER_PUBLIC_LOCATION,
'USER' : 'admin',
'PASSWORD' : 'geoserver',
'MAPFISH_PRINT_ENABLED' : True,
'PRINT_NG_ENABLED' : True,
'GEONODE_SECURITY_ENABLED' : True,
'GEOGIG_ENABLED' : False,
'WMST_ENABLED' : False,
'BACKEND_WRITE_ENABLED': True,
'WPS_ENABLED' : False,
'LOG_FILE': '%s/geoserver/data/logs/geoserver.log' % os.path.abspath(os.path.join(PROJECT_ROOT, os.pardir)),
# Set to dictionary identifier of database containing spatial data in DATABASES dictionary to enable
'DATASTORE': 'datastore', #'datastore',
}
}
# If you want to enable Mosaics use the following configuration
#UPLOADER = {
## 'BACKEND': 'geonode.rest',
# 'BACKEND': 'geonode.importer',
# 'OPTIONS': {
# 'TIME_ENABLED': True,
# 'MOSAIC_ENABLED': True,
# 'GEOGIG_ENABLED': False,
# }
#}
CATALOGUE = {
'default': {
# The underlying CSW implementation
# default is pycsw in local mode (tied directly to GeoNode Django DB)
'ENGINE': 'geonode.catalogue.backends.pycsw_local',
# pycsw in non-local mode
# 'ENGINE': 'geonode.catalogue.backends.pycsw_http',
# GeoNetwork opensource
# 'ENGINE': 'geonode.catalogue.backends.geonetwork',
# deegree and others
# 'ENGINE': 'geonode.catalogue.backends.generic',
# The FULLY QUALIFIED base url to the CSW instance for this GeoNode
'URL': '%scatalogue/csw' % SITEURL,
# 'URL': 'http://localhost:8080/geonetwork/srv/en/csw',
# 'URL': 'http://localhost:8080/deegree-csw-demo-3.0.4/services',
# login credentials (for GeoNetwork)
'USER': 'admin',
'PASSWORD': 'admin',
}
}
# Default preview library
# GEONODE_CLIENT_LAYER_PREVIEW_LIBRARY = 'geoext'
Initialize GeoNode¶
As user geonode, initialize the db, by creating the schema tables and populating the initial data::
cd /opt/apps/geonode/geonode/
python manage.py migrate
python manage.py loaddata geonode/base/fixtures/initial_data.json
Now create the admin user for GeoNode running the following:
python manage.py createsuperuser
You will be prompted for the username, email address and password for the user.
Warning
It is required to have at least one admin user called admin. If you want to break for security concerns this rule then you have to edit the default OAuth2 initial configuration geonode/base/fixtures/default_oauth_apps.json accordingly.
Finally create the default configuration for the OAuth2 application:
python manage.py loaddata geonode/base/fixtures/default_oauth_apps.json
In case your GeoNode will be exposed on a different port (i.e. 8001 in case of vagrant port forwarding) from the default 80 please make sure to do not forget to run the following commands:
Fix the site url from the local_settings file:
python manage.py fixsitename
Setting up OAuth2 configuration:
# Set oauth keys
export GEOSERVER_DATA_DIR=/var/lib/tomcat/webapps/geoserver/data
export NEWIP=localhost:8001 # Case of proxied geonode for example
oauth_keys=$(python manage.py fixoauthuri 2>&1)
oauth_keys_cleaned=$(echo $oauth_keys | cut -d " " -f 15)
client_id=`echo $oauth_keys_cleaned | cut -d \, -f 1`
client_secret=`echo $oauth_keys_cleaned | cut -d \, -f 2`
oauth_config="$GEOSERVER_DATA_DIR/security/filter/geonode-oauth2/config.xml"
sudo sed -i "s|<cliendId>.*</cliendId>|<cliendId>$client_id</cliendId>|g" $oauth_config
sudo sed -i "s|<clientSecret>.*</clientSecret>|<clientSecret>$client_secret</clientSecret>|g" $oauth_config
sudo sed -i "s/localhost:8000/localhost/g" $oauth_config
sudo sed -i "s|<userAuthorizationUri>.*</userAuthorizationUri>|<userAuthorizationUri>http://$NEWIP/o/authorize/</userAuthorizationUri>|g" $oauth_config
sudo sed -i "s|<logoutUri>.*</logoutUri>|<logoutUri>http://$NEWIP/account/logout/</logoutUri>|g" $oauth_config
sudo sed -i "s|localhost:8080/geoserver|$NEWIP/geoserver/|g" $oauth_config
sudo sed -i "s|localhost:8000|localhost|g" "$GEOSERVER_DATA_DIR/security/role/geonode REST role service/config.xml"
Restart Tomcat to load new configuration settings:
sudo systemctl restart tomcat@geoserver
Run the command updatelayers:
python manage.py updatelayers
Run the command updatemaplayerip:
python manage.py updatemaplayerip
Download GeoNode data to be served by Apache. You will be prompted for confirmation:
python manage.py collectstatic
Create uploaded folder:
mkdir -p /opt/apps/geonode/geonode/geonode/uploaded/
Isolate GeoNode installation¶
In case you prefer to isolate the GeoNode installation from the rest of your OS the most used strategy is to rely on a virtual environment. You can also install all the dependencies with a totally separated version of the python binary as explained in the section install_venv_httpd.