From e6f80497a9540acba8bbc55232e6ff55a3e6cd4c Mon Sep 17 00:00:00 2001 From: nicedevil007 <17103076+nicedevil007@users.noreply.github.com> Date: Sat, 18 Jun 2022 09:49:25 +0200 Subject: [PATCH] Updates with more packages Updated the manual installation file to get everybody up and running. There were missing requirements like the nginx installation and so on. Now a first time linux user should be able to get this up and running. --- docs/install/manual.md | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/docs/install/manual.md b/docs/install/manual.md index 3d6231dc6..ce88abf29 100644 --- a/docs/install/manual.md +++ b/docs/install/manual.md @@ -3,12 +3,17 @@ These instructions are inspired from a standard django/gunicorn/postgresql instructions ([for example](https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04)) !!! warning - Be sure to use python 3.9 and pip related to python 3.9. Depending on your distribution calling `python` or `pip` will use python2 instead of python 3.9. + Be sure to use python 3.9 at least and pip related to python 3.9 at least. Depending on your distribution calling `python` or `pip` will use python2 instead of python 3.9. As of writing this documentation 3.10 is available as well. + Make sure your machine got at least 2048 MB memory, otherwise the yarn build will fail with `FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory`. ## Prerequisites Setup user: `sudo useradd recipes` +Update the repositories and upgrade your OS: `sudo apt update && sudo apt upgrade -y` + +Install all prerequisits `sudo apt install -y git curl python3 python3-pip python3-venv nginx` + Get the last version from the repository: `git clone https://github.com/vabene1111/recipes.git -b master` Move it to the `/var/www` directory: `mv recipes /var/www` @@ -17,18 +22,18 @@ Change to the directory: `cd /var/www/recipes` Give the user permissions: `chown -R recipes:www-data /var/www/recipes` -Create virtual env: `python3.9 -m venv /var/www/recipes` +Create virtual env: `python3 -m venv /var/www/recipes` Install Javascript Tools (nodejs >= 12 required) ```shell ### Just use one of these possibilites! # Using Ubuntu curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - -sudo apt-get install -y nodejs +sudo apt install -y nodejs # Using Debian, as root curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - -apt-get install -y nodejs +apt install -y nodejs # Using a RPM based distro ## ... as root @@ -47,13 +52,13 @@ sudo npm install --global yarn ### Install postgresql requirements ```shell -sudo apt install libpq-dev postgresql +sudo apt install -y libpq-dev postgresql ``` ### Install LDAP requirements ```shell -sudo apt install libsasl2-dev python-dev libldap2-dev libssl-dev +sudo apt install -y libsasl2-dev python3-dev libldap2-dev libssl-dev ``` ### Install project requirements @@ -65,12 +70,13 @@ sudo apt install libsasl2-dev python-dev libldap2-dev libssl-dev Using binaries from the virtual env: ```shell -/var/www/recipes/bin/pip3.9 install -r requirements.txt +/var/www/recipes/bin/pip3 install -r requirements.txt ``` You will also need to install front end requirements and build them. For this navigate to the `./vue` folder and run ```shell +cd ./vue yarn install yarn build ``` @@ -96,6 +102,9 @@ ALTER ROLE djangouser SET timezone TO 'UTC'; --Grant superuser right to your new user, it will be removed later ALTER USER djangouser WITH SUPERUSER; + +--exit Postgres Environment +exit ``` Download the `.env` configuration file and **edit it accordingly**. @@ -105,7 +114,7 @@ wget https://raw.githubusercontent.com/vabene1111/recipes/develop/.env.template Things to edit: -- `SECRET_KEY`: use something secure. +- `SECRET_KEY`: use something secure (generate it with `base64 /dev/urandom | head -c50` f.e.). - `POSTGRES_HOST`: probably 127.0.0.1. - `POSTGRES_PASSWORD`: the password we set earlier when setting up djangodb. - `STATIC_URL`, `MEDIA_URL`: these will be in `/var/www/recipes`, under `/staticfiles/` and `/mediafiles/` respectively. @@ -114,11 +123,16 @@ Things to edit: Execute `export $(cat /var/www/recipes/.env |grep "^[^#]" | xargs)` to load variables from `/var/www/recipes/.env` -Execute `bin/python3.9 manage.py migrate` +Execute `./bin/python3 manage.py migrate` -and revert superuser from postgres: `sudo -u postgres psql` and `ALTER USER djangouser WITH NOSUPERUSER;` +and revert superuser from postgres: -Generate static files: `bin/python3.9 manage.py collectstatic` and `bin/python3.9 manage.py collectstatic_js_reverse` and remember the folder where files have been copied. +``` +sudo -u postgres psql` and `ALTER USER djangouser WITH NOSUPERUSER; +exit +``` + +Generate static files: `./bin/python3 manage.py collectstatic` and `./bin/python3 manage.py collectstatic_js_reverse` and remember the folder where files have been copied. ## Setup web services @@ -151,7 +165,7 @@ WantedBy=multi-user.target *Note2*: Fix the path in the `ExecStart` line to where you gunicorn and recipes are -Finally, run `sudo systemctl enable gunicorn_recipes` and `sudo systemctl start gunicorn_recipes`. You can check that the service is correctly started with `systemctl status gunicorn_recipes` +Finally, run `sudo systemctl enable --now gunicorn_recipes`. You can check that the service is correctly started with `systemctl status gunicorn_recipes` ### nginx @@ -190,6 +204,8 @@ Reload nginx : `sudo systemctl reload nginx` In order to update the application you will need to run the following commands (probably best to put them into a small script). ```shell +# change directory +cd /var/www/recipes # Update source files git pull # load envirtonment variables