Skip to content
aadeyemiadl edited this page Mar 8, 2024 · 7 revisions

Installation (with Docker)

Docker installation is the preferred method for deploying an instance of the ADL LRS, and we use this method for the live system.

This project will create Docker containers for the following services:

  • A Django web service (the ADL LRS) with uWSGI.
  • An nginx proxy handling HTTP/HTTPS traffic on ports 80/443
  • Postgres DB (LRS information and user accounts)
  • RabbitMQ (enabling Celery and AMQP)
  • Redis (session management)

TL;DR

  1. git clone https://github.com/adlnet/ADL_LRS
  2. cd ADL_LRS
  3. sudo bash ./install-lint.sh (🌟 NEW)
  4. cd ADL_LRS/docker
  5. cp .env.example .env (see below)
  6. cp settings.ini.example settings.ini (see below)
  7. sudo install-reqs.sh
  8. sudo init-ssl.sh localhost (🌟 NEW)
  9. sudo docker-compose up -d --build

Populating the Config Files

On the steps above, we create two config files called .env and settings.ini. These files provide the necessary variables to the containers and are required for the systems to operate properly. While most values can be left with their placeholders, things like HOSTNAME, SMTP_*, and RECAPTCHA_* values may need to be provided when standing up these systems in publicly accessible environments and some local environments.

Finally, to create an admin user (only use once the LRS is available, which can take awhile!)

sudo create-admin.sh

Setting up SSL

The project includes a basic Certbot container for generating a proper SSL certificate from a publicly available domain. To do this, run:

sudo ./certbot/generate.sh <your-domain-name>

This will retrieve a certificate and restart your nginx container to use it.

Note: If this fails for any reason, you will need to restore the temporary SSL cert using:

sudo ./init-ssl.sh <your-domain-name>

Connecting to a different database

To configure the database used by your LRS, refer to the settings.ini file and change the values under the [database] header accordingly.

Setting up SMTP

With Google as your email provider, refer to the settings.ini file and change the values under the [email] header.

With Office 365 or other email providers, be sure to enable TLS and not SSL.

Setting up a Site Name

By default, Django projects use a default site name of example.com which isn't ideal for a live system. To use an actual name:

sudo ./open-shell.sh

and then enter your Site info manually through the shell (type and enter each line):

from django.contrib.sites.models import Site
site = Site.objects.create(domain='your.domain.com', name='Your Site Name')
site.save()

Then update your settings.ini to change the SITE_ID to 2

[site]
SITE_ID: 2

Simplifying this process would be a welcome contribution.

Installation (without Docker)

Install Postgres

admin:~$ sudo apt-get install postgresql-9.5 postgresql-server-dev-9.5 postgresql-contrib-9.5

admin:~$ sudo -u postgres createuser -P -s <db_owner_name>
Enter password for new role: <db_owner_password>
Enter it again: <db_owner_password>
admin:~$ sudo -u postgres psql template1
template1=# CREATE DATABASE lrs OWNER <db_owner_name>;
template1=# \q (Exits shell.)

Install Prerequisites

admin:~$ sudo apt-get install git fabric python-setuptools python3-dev\
    libxml2-dev libxslt1-dev gcc
admin:~$ sudo pip3 install fabric3 virtualenv

Clone the LRS repository

admin:~$ cd <Wherever you want to put the LRS>
admin:~$ git clone https://github.com/adlnet/ADL_LRS.git
admin:~$ cd ADL_LRS/

Set the LRS configuration

Create a settings.ini file and place it in the adl_lrs directory. Visit the Settings wiki page to set it up.

Set Up the Environment

admin:ADL_LRS$ fab setup_env
admin:ADL_LRS$ source ../env/bin/activate
(env)admin:ADL_LRS$

Set Up the LRS

This creates the top level folders, logs and media at the same level as the project folder, ADL_LRS. Throughout the readme and the other install guides for celery and nginx you will most likely want to direct any log files to the logs directory. Inside of logs there are directorys for celery, supervisord, uwsgi and nginx.

(env)admin:ADL_LRS$ fab setup_lrs
...
You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use '<system_user_name>'):
E-mail address:
Password: <this can be different than your system password since this will just be for the LRS site>
Password (again):
Superuser created successfully.

...

If you get some sort of authentication error here, make sure that Django and PostgreSQL are both using the same form of authentication (adl_lrs/settings.py and pg_hba.conf) and that the credentials given in settings.py are the same as those you created.

IMPORTANT: You MUST setup celery for retrieving the activity metadata from the ID as well as voiding statements that might have come in out of order. Visit the Using Celery wiki page for installation instructions.

Starting

While still in the ADL_LRS directory, run:

(env)dbowner:ADL_LRS$ ./manage.py runserver

This starts a lightweight development web server on the local machine. By default, the server runs on port 8000 on the IP address 127.0.0.1. You can pass in an IP address and port number explicitly. This will serve your static files without setting up Nginx but must NOT be used for production purposes. Press CTRL + C to stop the server.

Set Your Site Domain

Visit the admin section of your website (/admin). Click Sites and you'll see the only entry is 'example.com'. (The key for this in the DB is 1 and it maps back to the SITE_ID value in settings). Change the domain and name to the domain you're going to use. If running locally it could be localhost:8000, or if production could be lrs.adlnet.gov (DON'T include the scheme here). Again, this does not change the domain it's running on; you want to set that up first then change this value to your domain name.

Whenever you want to exit the virtual environment, just type deactivate.

Test LRS

(env)dbowner:ADL_LRS$ fab test_lrs