From 89cfa7d93d4c241a58be3a360b2f7e98de836a66 Mon Sep 17 00:00:00 2001 From: John Martinez Date: Tue, 19 Sep 2023 18:32:13 +0000 Subject: [PATCH 1/4] Ran through the 'Ubuntu from Scratch' procedure using a fresh Ubuntu 22.04.3 LTS VM and took notes on what worked and what didn't. Here's a summary of the changes and why * added 'apt update' before the install -- only _needed_ on a completely fresh VM, but never hurts * added an install of the virtualenv package, because it is used later but: do you still need it AND python3-venv? I'm assuming it was done that way for a reason. * changed indentation on the mkdir so it will format correctly * added `-D ~postgres` to the commands executed as postgres user because the postgres user does not, by default, have permission to read into real user's home directories (at least in 22.04) and so the commands would error out * change `source ` to `. activate` because the line `sudo -u umap -i` launches `sh`, not `bash`, and `sh` does not recognize the source command. `.` works in either. * remove the instructions to change STATIC_ROOT and MEDIA_ROOT because they are already defaulted to those values in the current version sample of local.py * added a notice to change the SECREY_KEY and ADMINS list just because it seemed like a good idea. Side note: I have not seen any docs anywhere that explains exactly what the secret Key does, or where it is used. It's used a magic variable in the config file.. ? I am not currently messing with nginx or wsgi, so I can't comment on those parts. --- docs/ubuntu.md | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/docs/ubuntu.md b/docs/ubuntu.md index 8126dd0d..1de12fe2 100644 --- a/docs/ubuntu.md +++ b/docs/ubuntu.md @@ -6,13 +6,14 @@ You need sudo grants on this server, and it must be connected to Internet. ## Install system dependencies - sudo apt install python3 python3-dev python3-venv wget nginx uwsgi uwsgi-plugin-python3 postgresql gcc postgis libpq-dev + sudo apt update + sudo apt install python3 python3-dev python3-venv virtualenv wget nginx uwsgi uwsgi-plugin-python3 postgresql gcc postgis libpq-dev *Note: nginx and uwsgi are not required for local development environment* ## Create deployment directories: - sudo mkdir -p /etc/umap + sudo mkdir -p /etc/umap *You can change this path, but then remember to adapt the other steps accordingly.* @@ -33,17 +34,17 @@ on the various commands and configuration files if you go with your own.* ## Create a postgresql user - sudo -u postgres createuser umap + sudo -u postgres -D ~postgres createuser umap ## Create a postgresql database - sudo -u postgres createdb umap -O umap + sudo -u postgres -D ~postgres createdb umap -O umap ## Activate PostGIS extension - sudo -u postgres psql umap -c "CREATE EXTENSION postgis" + sudo -u postgres -D ~postgres psql umap -c "CREATE EXTENSION postgis" ## Login as umap Unix user @@ -55,8 +56,8 @@ From now on, unless we say differently, the commands are run as `umap` user. ## Create a virtualenv and activate it - virtualenv /srv/umap/venv --python=/usr/bin/python3.6 - source /srv/umap/venv/bin/activate + virtualenv /srv/umap/venv --python=/usr/bin/python3.10 + . /srv/umap/venv/bin/activate *Note: this activation is not persistent, so if you open a new terminal window, you will need to run again this last line.* @@ -75,12 +76,8 @@ you will need to run again this last line.* nano /etc/umap/umap.conf -Change the following properties: - -``` -STATIC_ROOT = '/srv/umap/var/static' -MEDIA_ROOT = '/srv/umap/var/data' -``` +* update the SECRET_KEY +* update the ADMINS list ## Create the tables From e2eb5108540c96bf54785164646d7b8113f2202a Mon Sep 17 00:00:00 2001 From: John Martinez Date: Tue, 19 Sep 2023 18:49:21 +0000 Subject: [PATCH 2/4] Add link to django docs for SECRET_KEY --- docs/settings.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/settings.md b/docs/settings.md index ba08de12..e741c3ab 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -61,7 +61,7 @@ See [Django documentation for MEDIA_ROOT](https://docs.djangoproject.com/en/4.2/ #### SECRET_KEY -Must be defined to something unique and secret. +Must be defined to something unique and secret. (See https://docs.djangoproject.com/en/4.2/ref/settings/#std:setting-SECRET_KEY if you want to know more.) #### SITE_URL From 7134269218ee4f11f6e142892f00c65a078999c9 Mon Sep 17 00:00:00 2001 From: John Martinez Date: Tue, 19 Sep 2023 14:58:21 -0400 Subject: [PATCH 3/4] Update docs/ubuntu.md Co-authored-by: David Larlet <3556+davidbgk@users.noreply.github.com> --- docs/ubuntu.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ubuntu.md b/docs/ubuntu.md index 1de12fe2..46065584 100644 --- a/docs/ubuntu.md +++ b/docs/ubuntu.md @@ -76,7 +76,7 @@ you will need to run again this last line.* nano /etc/umap/umap.conf -* update the SECRET_KEY +* update the [SECRET_KEY](settings.md#secret_key) * update the ADMINS list ## Create the tables From 408fcb7c0f08d50e8fadf82a2c5395e414d681e9 Mon Sep 17 00:00:00 2001 From: David Larlet Date: Tue, 19 Sep 2023 14:59:31 -0400 Subject: [PATCH 4/4] Revert "Add link to django docs for SECRET_KEY" This reverts commit e2eb5108540c96bf54785164646d7b8113f2202a. --- docs/settings.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/settings.md b/docs/settings.md index e741c3ab..ba08de12 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -61,7 +61,7 @@ See [Django documentation for MEDIA_ROOT](https://docs.djangoproject.com/en/4.2/ #### SECRET_KEY -Must be defined to something unique and secret. (See https://docs.djangoproject.com/en/4.2/ref/settings/#std:setting-SECRET_KEY if you want to know more.) +Must be defined to something unique and secret. #### SITE_URL