Installing natively

This page describes the procedure to install and run PrairieLearn without any use of Docker. This means that PrairieLearn is running fully natively on the local OS. This installation method is tested and supported on MacOS and Linux, but not on Windows. It should also work on Windows, but it is not tested.

On OS X these can be installed with MacPorts or Homebrew. On Linux these should all be standard packages from the OS distrbution.

Note that with MacPorts you need to select the active version of PostgreSQL, for example port select postgresql postgresql96.

  • Clone the latest code:
git clone https://github.com/PrairieLearn/PrairieLearn.git
  • Install the Node.js libraries:
cd PrairieLearn
npm ci

On OS X, it is possible that this process will fail on node-gyp rebuild during the install of mcrypt. In this case, use the following command instead:

npm ci --python=PATH_TO_PYTHON2

For example, this might be:

npm ci --python=/usr/bin/python2.7
  • Make sure python3 and python3.6 will run the right version, and make executable links if needed:
python3 --version     # should return "Python 3.6" or higher
python3.6 --version   # should return "Python 3.6" or higher
  • Install the Python libraries:
cd PrairieLearn
python3 -m pip install -r requirements.txt
  • Create the database (one time only):
initdb -D ~/defaultdb
  • Run the database:
pg_ctl -D ~/defaultdb -l ~/logfile start
  • Make sure the postgres database user exists and is a superuser (these might error if the user already exists):
psql -c "CREATE USER postgres;"
psql -c "ALTER USER postgres WITH SUPERUSER;"
  • Run the test suite:
cd PrairieLearn
npm test
  • Run the linters:
cd PrairieLearn
npm run lint-js -s
npm run lint-python -s
  • Create the file PrairieLearn/config.json with the path of your local course repository and with the path of a directory into which temporary files will be saved when using the in-browser file editor (edit both paths as needed):
{
    "courseDirs": [
        "/Users/mwest/git/pl-tam212",
        "exampleCourse"
    ],
    "filesRoot": "../filesRoot"
}
  • Run the server:
cd PrairieLearn
node server

This should end with PrairieLearn server ready and will remain running in the foreground, so this terminal can't be used for anything else. Stopping or restarting the server can be done with Crtl-C.