Manual Server Configuration

Parent Previous Next

Manual Remote Database Configuration

Rather than use the above automated script, server configuration can be performed manually. The initial database is essentially the same, but several steps must be performed manually. In this example, the Nexus rpm was installed to a local folder using the command:

rpm -i --prefix=$ROOT/cei_home Nexus-1.0.0a-1.x86_64.rpm

Configure the Database

Start with the Remote Database Setup to configure the PostgreSQL server. The PostgreSQL database needs to be initialized with the Nexus content.  To do this, we use the Django '' tool.

Set up the environmental variables:

rjflinux% DATABASE=/home/nexus/NexusInstance

rjflinux% cd $DATABASE

rjflinux% CEI=/opt/CEI

rjflinux% PATH=$CEI/bin:$PATH

rjflinux% export CEI_NEXUS_DB_USER=nexus

rjflinux% export CEI_NEXUS_DB_PASSWORD=cei

rjflinux% export

Validate the configuration:

rjflinux% cpython $CEI/nexus193/django/ check

Initialize the database tables:

rjflinux% cpython $CEI/nexus193/django/ migrate

Operations to perform:

  Synchronize unmigrated apps: staticfiles, admindocs, messages, rest_framework

  Apply all migrations: sessions, admin, reports, contenttypes, auth, data

Synchronizing apps without migrations:

  Creating tables...

    Running deferred SQL...

  Installing custom SQL...

Running migrations:

  Rendering model states... DONE

  Applying contenttypes.0001_initial... OK

  Applying auth.0001_initial... OK

  Applying admin.0001_initial... OK

  Applying contenttypes.0002_remove_content_type_name... OK

  Applying auth.0002_alter_permission_name_max_length... OK

  Applying auth.0003_alter_user_email_max_length... OK

  Applying auth.0004_alter_user_username_opts... OK

  Applying auth.0005_alter_user_last_login_null... OK

  Applying auth.0006_require_contenttypes_0002... OK

  Applying data.0001_initial... OK

  Applying data.0002_auto_20160609_0913... OK

  Applying data.0003_auto_20160614_1033... OK

  Applying data.0004_auto_20160614_1105... OK

  Applying data.0005_auto_20160629_1556... OK

  Applying reports.0001_initial... OK

  Applying reports.0002_auto_20160812_1428... OK

  Applying reports.0003_template_children_order... OK

  Applying sessions.0001_initial... OK

Finally, we add the administration username to the Nexus database. This is the username that can access the Nexus administration functions.

rjflinux% cpython $CEI/nexus193/django/ createsuperuser --username nexus

Email address:


Password (again):

Superuser created successfully.

The next steps are to create the various configuration files.

Remote Web Server Setup

In the local server case, the Nexus instance itself becomes the web server. In a production, multi-user environment, the web server is external, provided by the hosting site. The web server provides proxy authentication and authorization to the Nexus instance. It is also used to directly serve images, movies, and geometry to the user. An example using the NGINX server on an Ubuntu Linux installation, assuming a standard NGINX installation, is shown here:

Changes to /etc/NGINX/NGINX.conf, in the 'http' section, add:

# Allow large POST requests

client_max_body_size 500M;

include /etc/NGINX/sites-enabled/*;

Be sure to remove any ‘server’ sections that conflict with the URL you wish to point to the Nexus server.

In the directory /etc/NGINX/sites-enabled, add the file nexus.conf (likely generated when you ran the nexus_remotedb_config10 script):

server {

    server_name {NEXUS.MYSERVERNAME.COM};

    access_log off;

    location /static/admin/ {

        root {CEI_HOME}/apex32/machines/linux_2.6_64/Python-2.7.11/lib/python2.7/site-packages/django/contrib/admin/;


    location /static/rest_framework/ {

        root {CEI_HOME}/apex32/machines/linux_2.6_64/Python-2.7.11/lib/python2.7/site-packages/rest_framework/;


    location /static/ {

        root {CEI_HOME}/nexus193/django/website/;


    location /media/ {



    location / {


        proxy_set_header X-Forwarded-Host $server_name;

        proxy_set_header X-Real-IP $remote_addr;

        add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';



The text within {} must be customized to your site. You will need to restart NGINX after making these changes. There are several different ways to do this depending on the host platform. A common one is:

sudo service NGINX restart

With this configuration in place, http://NEXUS.MYSERVERNAME.COM should return an 'Invalid Gateway' when accessed via NGINX without a Nexus instance running. If a Nexus instance is running on port 8001 on the same system running the NGINX server, you will see the Nexus root web page.

The key elements are:

    1. Configure NGINX to serve files for /static/admin, /static/rest_framework, /static, and /media directly.
    2. Ensure that NGINX can handle large (largest .mp4 file allowed) REST POST requests.
    3. Map the URL root ('/') to the instance of the Nexus server.

Parallel WSGI Server Setup

Once the NGINX server is up and running, it may be desirable to run multiple copies of the Nexus framework in order to allow queries to be handled in parallel. There are many different ways of doing this, but in this example, we will use Gunicorn to set up a WSGI gateway to the NGINX server.

We will configure Gunicorn to run five concurrent instances of the Nexus framework on the local machine. In conjunction with the NGINX configuration above that expects a proxy server on the localhost (, we will run this Nexus instance to serve up at that URL. Start with a Gunicorn configuration file The contents of this file in our example are:


# Basic gunicorn configuration settings

# how to launch itself, where is the django instance,

# what local port should NGINX look to proxy, # of

# workers and the user to run the system as.


command = '/opt/CEI/apex32/machines/linux_2.6_64/Python-2.7.11/bin/gunicorn'

pythonpath = '/home/nexus/LocalServerHome'

bind = ''

workers = 5

user = 'nexus'

This file tells Gunicorn to launch five instances of the Nexus framework bound to using the username 'nexus'. We are using the Gunicorn command from the Python distribution installed at /opt/CEI. A shell script can then be used to launch the servers. (This is the script that is generated by nexus_remotedb_config10, above).






cd $ROOT

# configure Nexus server instance environmental variables here


# migrate updates and launch the server via gunicorn

cpython $CEI_HOME/nexus193/django/ migrate

cpython $CEI_HOME/nexus193/django/

gunicorn -c ceireports.wsgi

Note: every instance of the WSGI interface will check out and hold a SLiM license. In the example, five Nexus remote server license instances will be checked out.

A more complex startup script example running on AWS might take this form:


# The CEI Nexus rpm install is local to the directory: /home/ec2-user/cei_home




# The Nexus database is located at /home/ec2-user/nexus_database

# (e.g. /home/ec2-user/nexus_database/media is the media root location)


# PostgreSQL RDS database access

export CEI_NEXUS_DB_USER=my_postgresql_db_username

export CEI_NEXUS_DB_PASSWORD=my_postgresql_db_password


# Location of the slim8.key file

export NEXUS_LICENSE_FILE_DIRECTORY=/home/ec2-user/nexus_database/license

cd $ROOT/nexus_database

cpython $ROOT/cei_home/CEI/nexus193/django/ migrate

cpython $ROOT/cei_home/CEI/nexus193/django/

gunicorn -c ceireports.wsgi