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
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 'manage.py' 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 CEI_NEXUS_DB_HOSTNAME=postgre01.ceintl.com
Validate the configuration:
rjflinux% cpython $CEI/nexus193/django/manage.py check
Initialize the database tables:
rjflinux% cpython $CEI/nexus193/django/manage.py 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/manage.py createsuperuser --username nexus
Email address: foo@bar.com
Password:
Password (again):
Superuser created successfully.
The next steps are to create the various configuration files.
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/ {
root {/DIRECTORY/NAME/CONTAINING/media/DIRECTORY}/;
}
location / {
proxy_pass http://127.0.0.1:8001/;
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:
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 (http://127.0.0.1:8001), we will run this Nexus instance to serve up at that URL. Start with a Gunicorn configuration file gunicorn_cfg.py. The contents of this file in our example are:
#
# gunicorn_cfg.py: 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 = '127.0.0.1:8001'
workers = 5
user = 'nexus'
This file tells Gunicorn to launch five instances of the Nexus framework bound to http://127.0.0.1:8001 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 start_server.sh script that is generated by nexus_remotedb_config10, above).
#!/bin/sh
ROOT=/home/nexus/LocalServerHome
PATH=/opt/CEI/bin:$PATH
PATH=/opt/CEI/apex32/machines/linux_2.6_64/Python-2.7.11/bin:$PATH
PATH=$ROOT:$PATH
cd $ROOT
# configure Nexus server instance environmental variables here
export SLIMD8_SERVERS=slim_server.somedomain.com:7790
# migrate updates and launch the server via gunicorn
cpython $CEI_HOME/nexus193/django/manage.py migrate
cpython $CEI_HOME/nexus193/django/update_geometry.py
gunicorn -c gunicorn_cfg.py 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:
#!/bin/sh
# The CEI Nexus rpm install is local to the directory: /home/ec2-user/cei_home
ROOT=/home/ec2-user
PATH=$ROOT/cei_home/CEI/bin:$PATH
PATH=$ROOT/cei_home/CEI/apex32/machines/linux_2.6_64/Python-2.7.11/bin:$PATH
# The Nexus database is located at /home/ec2-user/nexus_database
# (e.g. /home/ec2-user/nexus_database/media is the media root location)
PATH=$ROOT/nexus_database:$PATH
# PostgreSQL RDS database access
export CEI_NEXUS_DB_USER=my_postgresql_db_username
export CEI_NEXUS_DB_PASSWORD=my_postgresql_db_password
export CEI_NEXUS_DB_HOSTNAME=example.my_region.rds.amazonaws.com
# 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/manage.py migrate
cpython $ROOT/cei_home/CEI/nexus193/django/update_geometry.py
gunicorn -c gunicorn_cfg.py ceireports.wsgi