-
-
Notifications
You must be signed in to change notification settings - Fork 9
Development Installation
Brian Pepple edited this page Jan 4, 2025
·
4 revisions
Note: These instructions are based on installing on Fedora Linux, so they will need to be modified accordingly depending on your operating system.
- Run the following commands in Terminal:
- Install redis, postgresql, and python3.12:
sudo dnf install postgresql-server postgresql-contrib redis python3.12 - Initialize postgresql:
sudo postgresql-setup --initdb --unit postgresqlNote: If you're using Ubuntu, you can skip this step. - Start postgresql and redis:
sudo systemctl start postgresql redis - Change to the postgres user:
sudo su - postgres - Log into a Postgres session by typing:
psql - Create a database for our Django project (substitute something more descriptive than 'myproject'):
CREATE DATABASE myproject; - Create a database user which we will use to connect to and interact with the database:
CREATE USER myprojectuser WITH PASSWORD 'password'; - 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';
- Give our database user access rights to the database we created:
GRANT ALL PRIVILEGES ON DATABASE myproject TO myprojectuser; - Exit the SQL prompt to get back to the postgres user's shell session:
\q - Exit out of the postgres user's shell session to get back to your regular user's shell session:
exit
- Install redis, postgresql, and python3.12:
- Run the following commands in Terminal:
- Install pipenv:
sudo dnf install pipenv - Git clone the repo:
git clone git@github.com:bpepple/metron.git - Change to the directory where you cloned Metron. For example, if you want to install this in your Documents folder:
cd ~/Documents/metron - Activate the pipenv shell:
pipenv shell - Install the Metron dependencies:
pipenv sync --dev. Note: Refer to this to install the prerequisites for psycopg2. - Edit metron/.env.example, and find the
DATABASESsection and edit the values for theDB_NAME,DB_USER,DB_PASSWORD, with the information from when you set-up the postgresql database in Section 1. - Generate a secret key (for Django security) at Django-Secret-Key, and add this value to the
SECRET_KEYin your .env file. - Edit the
STATIC_ROOTandMEDIA_ROOTkeys to where you would like to save files. - Copy the example environment file for production use:
cp .env.example .env - Create your database:
python3 manage.py migrate - Create your admin user:
python3 manage.py createsuperuser
- Install pipenv:
- Start your local server:
python3 manage.py runserver- For example:
python3 manage.py runserver
- For example:
- In your browser, go to
http://[YOUR IP ADDRESS]:8000/- For example:
http://192.168.1.30:8000/
- For example: