Install GeoNode for Development

In order to install Geonode 2.4 in development mode on Ubuntu 14.04 the following steps are required:

For Windows: (Install GeoNode for Development (Windows))

For CentOS 7: (Install GeoNode on CentOS 7 (dev mode))

Summary of the installation steps

  1. Retrieve latest apt-get list
  2. Install build tools and libraries
  3. Install dependencies (Python, Postgresql and Java) and supporting tools
  4. Add Node.js PPA and other tools required for static development
  5. Set up a virtual environment (virtualenv)
  6. Clone geonode from GitHub and install it in the virtual environment
  7. Run paver to get install GeoServer and start the development servers
  8. Compile and Start the server
  9. Start Geonode instance
  10. To stop the server
  11. Next create a Django superuser for your GeoNode

Note

The following steps have to be executed in your terminal. The steps have to be done as a root user, therefore don´t forget to type sudo in front!

Warning

Don’t forget to stop the GeoNode Production services if enabled

service apache2 stop
service tomcat7 stop
  1. If possible log as root user, open a terminal and cd /home/geonode/dev

  2. Retrieve latest apt-get list

    $ sudo apt-get update
    
  3. Install build tools and libraries

    $ sudo apt-get install -y build-essential libxml2-dev libxslt1-dev libpq-dev zlib1g-dev
    
  4. Install dependencies

    Python native dependencies

    $ sudo apt-get install -y python-dev python-imaging python-lxml python-pyproj python-shapely python-nose python-httplib2 python-pip python-software-properties
    

    Install Python Virtual Environment

    $ sudo pip install virtualenvwrapper
    

    PostgreSQL & PostGIS

    Note

    The following steps must be executed only if you don’t have PostgreSQL and PostGIS already installed on your system (see Install GeoNode Application)

    
    

    $ sudo apt-get install -y postgresql-9.3-postgis-2.1 postgresql-9.3-postgis-scripts

    Change postgres UNIX password

       $ sudo passwd -u postgres # change password expiry infromation
    
       $ sudo passwd postgres # change unix password for postgres
    
    Create GeoNode role and database
    
        .. code-block:: console
    
           $ su postgres
           $ createdb geonode_dev
           $ createdb geonode_dev-imports
           $ psql
             postgres=#
             postgres=# \password postgres
             postgres=# CREATE USER geonode_dev WITH PASSWORD 'geonode_dev'; # should be same as password in setting.py
             postgres=# GRANT ALL PRIVILEGES ON DATABASE "geonode_dev" to geonode_dev;
             postgres=# GRANT ALL PRIVILEGES ON DATABASE "geonode_dev-imports" to geonode_dev;
             postgres=# \q
    
           $ psql -d geonode_dev-imports -c 'CREATE EXTENSION postgis;'
           $ psql -d geonode_dev-imports -c 'GRANT ALL ON geometry_columns TO PUBLIC;'
           $ psql -d geonode_dev-imports -c 'GRANT ALL ON spatial_ref_sys TO PUBLIC;'
    
           $ exit
    

    Edit PostgreSQL configuration file

    sudo gedit /etc/postgresql/9.3/main/pg_hba.conf
    

    Scroll to the bottom of the file and edit this line

    # "local" is for Unix domain socket connections only
    local   all             all                            peer
    

    As follows

    # "local" is for Unix domain socket connections only
    local   all             all                                trust
    

    Restart PostgreSQL to make the changes effective

    sudo service postgresql restart
    

    Java dependencies

    Note

    The following steps must be executed only if you don’t have a Java JDK or JRE already installed on your system (see Install GeoNode Application)

    
    

    $ sudo apt-get install -y –force-yes openjdk-7-jdk –no-install-recommends

    Supporting tools

    
    

    $ sudo apt-get install -y git gettext libjpeg62 libjpeg62-dev

  5. Set up a virtual environment

    This is the local environment where Geonode will later be running.

    Add the virtualenvwrapper to your new environment.

    $ cd /home/geonode/dev
    
    $ export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python
    $ export WORKON_HOME=/home/geonode/dev/.venvs
    $ source /usr/local/bin/virtualenvwrapper.sh
    $ export PIP_DOWNLOAD_CACHE=$HOME/.pip-downloads
    

    On Ubuntu, you can add the above settings to your .bashrc file and reload the settings running

    $ echo export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python >> ~/.bashrc
    $ echo export WORKON_HOME=/home/geonode/dev/.venvs >> ~/.bashrc
    $ echo source /usr/local/bin/virtualenvwrapper.sh >> ~/.bashrc
    $ echo export PIP_DOWNLOAD_CACHE=$HOME/.pip-downloads >> ~/.bashrc
    
    $ source ~/.bashrc
    

    Set up the local virtual environment for Geonode

    $ mkvirtualenv geonode
    $ workon geonode # or $ source /home/geonode/dev/.venvs/geonode/bin/activate
    

    This creates a new directory where you want your project to be and creates a new virtualenvironment

  6. Get the GeoNode source code

    To download the latest GeoNode version from GitHub, the command clone is used

    Note

    If you are following the GeoNode training, skip the following command. You can find the cloned repository in /home/geonode/dev

    $ git clone https://github.com/GeoNode/geonode.git
    
  7. Add Node.js PPA and other tools required for static development

    This is required for static development

    Note

    If you are following GeoNode’s training, nodejs is already installed in the Virtual Machine skip the first three command and jump to cd geonode/geonode/static

    $ sudo add-apt-repository -y ppa:chris-lea/node.js
    $ sudo apt-get update
    $ sudo apt-get install -y nodejs
    $ cd geonode/geonode/static
    $ npm install --save-dev
    
    # If the last command does not work, you can run it manually like this:
    
    $ npm install bower --save-dev
    $ npm install grunt-cli --save-dev
    $ npm install grunt-contrib-jshint --save-dev
    $ npm install grunt-contrib-less --save-dev
    $ npm install grunt-contrib-concat --save-dev
    $ npm install grunt-contrib-copy --save-dev
    $ npm install grunt-text-replace --save-dev
    $ npm install grunt-contrib-uglify --save-dev
    $ npm install grunt-contrib-cssmin --save-dev
    $ npm install grunt-contrib-watch --save-dev
    

    Note

    Every time you want to update the static files after making changes to the sources, go to geonode/static and run ‘grunt production’.

  8. Install GeoNode in the new active local virtualenv

    $ cd /home/geonode/dev
    $ pip install pip --upgrade
    $ pip install -e geonode --use-mirrors
    
    $ cd geonode
    

    If the install fails because of an error related to pyproj not being verified (happens on pip 1.5), use the following:

    $ pip install -e geonode --use-mirrors --allow-external pyproj --allow-unverified pyproj
    
  9. Create local_settings.py

    Add the local_settings.py to your GeoNode installation

    $ cd /home/geonode/dev/geonode
    $ cp geonode/local_settings.py.sample geonode/local_settings.py
    $ gedit geonode/local_settings.py
    

    Add the following lines to the local_settings.py

    ...
    
    SITEURL = "http://localhost:8000/"
    
    DATABASES = {
        'default': {
             'ENGINE': 'django.db.backends.postgresql_psycopg2',
             'NAME': 'geonode_dev',
             'USER': 'geonode_dev',
             'PASSWORD': 'geonode_dev',
         },
        # vector datastore for uploads
        'datastore' : {
            'ENGINE': 'django.contrib.gis.db.backends.postgis',
            #'ENGINE': '', # Empty ENGINE name disables
            'NAME': 'geonode_dev-imports',
            'USER' : 'geonode_dev',
            'PASSWORD' : 'geonode_dev',
            'HOST' : 'localhost',
            'PORT' : '5432',
        }
    }
    
    # OGC (WMS/WFS/WCS) Server Settings
    OGC_SERVER = {
        'default' : {
            'BACKEND' : 'geonode.geoserver',
            'LOCATION' : 'http://localhost:8080/geoserver/',
            'PUBLIC_LOCATION' : 'http://localhost:8080/geoserver/',
            '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 name of database in DATABASES dictionary to enable
            'DATASTORE': 'datastore',
        }
    }
    
    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',
        }
    }
    
    ...
    
  10. Compile and Start the server for the first time

    Align the database structure

    $ cd /home/geonode/dev/geonode
    $ python manage.py migrate
    

    Warning

    If the start fails because of an import error related to osgeo, then please consult the Install GDAL for Development.

    The last step is to compile GeoServer and setup, then initialize the database

    $ paver setup
    $ paver sync
    
  11. Now we can start our GeoNode instance

    Warning

    Don’t forget to stop the GeoNode Production services if enabled

    service apache2 stop
    service tomcat7 stop
    
    $ paver start
    

    Visit the GeoNode site by typing http://localhost:8000 into your browser window.

    If you are using a different IP address (e.g 1.1.1.1), then start paver using the command below.

    $ paver start -b 1.1.1.1:8000
    

    Warning

    If the start fails because of an import error related to osgeo, then please consult the Install GDAL for Development.

  12. To stop the server

    Press Ctrl-C on your keyboard to stop the server.

    then type:

    $ paver stop    # to stop all django, geoserver services
    
  13. Create a Django superuser for your GeoNode

    Create a superuser so you can log on to your local GeoNode installation at http://localhost:8000

    $ python manage.py createsuperuser
    

Start working on Geonode the next day after install

With every restart of your machine, you have to restart GeoNode as well. That means, you will not be able to open http://localhost:8000 directly after starting your machine new. In order to be able to use GeoNode now, you have to activate your virtualenv and to start the development servers.

Note

username is the name of your machine and personal folder!

  1. Activate virtualenv

    To activate your virtualenv you just need to type

    $ workon geonode
    

    or

    $ source /home/geonode/dev/.venvs/geonode/bin/activate
    

    Note

    Be careful with the path, it might not be the same for you!

  2. Start the server

    Warning

    Don’t forget to stop the GeoNode Production services if enabled

    service apache2 stop
    service tomcat7 stop
    
    $ cd geonode
    $ paver start_geoserver
    $ paver start_django
    

    Now you are able to access http://localhost:8000 again.

    Note

    Remember that you have to do these steps each time you restart your machine!!

Hint

Now you’ve followed these installation instructions, GeoNode is running in development mode. This also means that you are using all the default settings of GeoNode. If you want to change them, e.g use Tomcat instead of Jetty, or Postgresql instead of sqlite3, you may follow the steps from the section Configure Manually in Custom Installation Guide.