Skip to content

Development Installation

Brian Pepple edited this page Jan 25, 2022 · 1 revision

Note: These instructions are based on installing on Fedora Linux, so they will need to be modified accordingly depending on your operating system.

Install Python3.8, Postgresql and Redis

  1. Run the following commands in Terminal:
    1. Install redis, postgresql, and python3.8: sudo dnf install postgresql-server postgresql-contrib redis python3.8
    2. Initialize postgresql: sudo postgresql-setup --initdb --unit postgresql Note: If you're using Ubuntu, you can skip this step.
    3. Start postgresql and redis: sudo systemctl start postgresql redis
    4. Change to the postgres user: sudo su - postgres
    5. Log into a Postgres session by typing: psql
    6. Create a database for our Django project (substitute something more descriptive than 'myproject'): CREATE DATABASE myproject;
    7. Create a database user which we will use to connect to and interact with the database: CREATE USER myprojectuser WITH PASSWORD 'password';
    8. We are setting the default encoding to UTF-8, which Django expects. We are also setting the default transaction isolation scheme to "read committed", which blocks reads from uncommitted transactions.:
      • ALTER ROLE myprojectuser SET client_encoding TO 'utf8';
      • ALTER ROLE myprojectuser SET default_transaction_isolation TO 'read committed';
      • ALTER ROLE myprojectuser SET timezone TO 'UTC';
    9. Give our database user access rights to the database we created: GRANT ALL PRIVILEGES ON DATABASE myproject TO myprojectuser;
    10. Exit the SQL prompt to get back to the postgres user's shell session: \q
    11. Exit out of the postgres user's shell session to get back to your regular user's shell session: exit

Install Metron

  1. Run the following commands in Terminal:
    1. Install pipenv: sudo dnf install pipenv
    2. Git clone the repo: git clone git@github.com:bpepple/metron.git
    3. Change to the directory where you cloned Metron. For example, if you want to install this in your Documents folder: cd ~/Documents/metron
    4. Activate the pipenv shell: pipenv shell
    5. Install the Metron dependencies: pipenv sync --dev. Note: Refer to this to install the prerequisites for psycopg2.
    6. Edit metron/.env.example, and find the DATABASES section and edit the values for the DB_NAME, DB_USER, DB_PASSWORD, with the information from when you set-up the postgresql database in Section 1.
    7. Generate a secret key (for Django security) at Django-Secret-Key, and add this value to the SECRET_KEY in your .env file.
    8. Edit the STATIC_ROOT and MEDIA_ROOT keys to where you would like to save files.
    9. Copy the example environment file for production use: cp .env.example .env
    10. Create your database: python3 manage.py migrate
    11. Create your admin user: python3 manage.py createsuperuser

Get Running!

  1. Start your local server: python3 manage.py runserver
    • For example: python3 manage.py runserver
  2. In your browser, go to http://[YOUR IP ADDRESS]:8000/
    • For example: http://192.168.1.30:8000/