-
Notifications
You must be signed in to change notification settings - Fork 64
Installation guide with CentOS 7
For the sake of simplicity, this guide assumes the following environment:
- CentOS 7 (operating system)
- Python 3.6
- Gunicorn (Python WSGI server)
- Nginx (static content server and reverse proxy)
- SQLite (database)
There is nothing to prevent you from using NEMO in a different environment, however, we have only tested NEMO in this production environment.
Download and install the following packages in order to compile Python. Also create a nemo
user which will run the NEMO application and web server.
yum -y install gcc wget sqlite-devel openssl-devel git
useradd -c "NEMO" nemo
To compile and install Python...
cd /home/nemo
wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz
tar xf Python-3.6.2.tgz
cd Python-3.6.2/
./configure --prefix=/home/nemo/python
make
make install
cd /home/nemo
rm -rf Python-3.6.2 Python-3.6.2.tgz
Python is now installed in the /home/nemo/python/
directory.
You'll need to set some environment variables to specify the location of the Python interpreter, and where NEMO should read its settings from.
All Django projects (including NEMO) read in their settings from one important file: settings.py
. The Django documentation states you should specify the settings location using the environment variable DJANGO_SETTINGS_MODULE
. The value of DJANGO_SETTINGS_MODULE
should be in Python path syntax.
Additionally, the settings file should be on the Python import search path. You will probably also need to set PYTHONPATH
to the directory that contains the settings file. For example, if the file settings.py
resides in the directory /home/nemo/
, you would set PYTHONPATH=/home/nemo
and DJANGO_SETTINGS_MODULE=settings
.
Edit /home/nemo/.bashrc
to set environment variables to point to the correct Python interpreter and settings by adding:
PATH=/home/nemo/python/bin:$PATH
PYTHONPATH=/home/nemo
DJANGO_SETTINGS_MODULE="settings"
export PATH PYTHONPATH DJANGO_SETTINGS_MODULE
Refresh the environment variables by closing the bash terminal and reopening it as the nemo
user. Ensure the proper Python interpreter is available in your PATH
environment variable using which python3
... the first line of output should be /home/nemo/python/bin
.
pip3 install git+https://github.com/usnistgov/NEMO.git
You will need a place to store media and static content that NEMO uses:
cd /home/nemo
mkdir media static
You'll need to generate a secret key which is used by Django for password and session hashing. The NEMO package comes with an executable script that assists with this. nemo generate_secret_key
will output a random 50 character key to standard output, which can be redirected to a file.
nemo generate_secret_key > django_secret_key.txt
Reference this file in your settings.py
by assigning
SECRET_KEY = get_file_contents('/path/to/django_secret_key.txt')
.
cd /home/nemo/
python3 manage.py makemigrations NEMO
python3 manage.py migrate
To start NEMO on the command line: gunicorn NEMO.wsgi:application
This will serve NEMO on the default address for Gunicorn: 127.0.0.1:8000
.
To test NEMO by fetching the root URL, use: curl 127.0.0.1:8000
or curl localhost:8000
- systemd configuration (automatic startup on boot, and more)
- ensure the firewall is open on TCP port 443
- Nginx reverse proxy and static content server