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.
This commit is contained in:
nicedevil007
2022-06-18 09:49:25 +02:00
committed by GitHub
parent 6c122e4ed0
commit e6f80497a9

View File

@@ -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)) 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 !!! 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 ## Prerequisites
Setup user: `sudo useradd recipes` 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` 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` 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` 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) Install Javascript Tools (nodejs >= 12 required)
```shell ```shell
### Just use one of these possibilites! ### Just use one of these possibilites!
# Using Ubuntu # Using Ubuntu
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - 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 # Using Debian, as root
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
apt-get install -y nodejs apt install -y nodejs
# Using a RPM based distro # Using a RPM based distro
## ... as root ## ... as root
@@ -47,13 +52,13 @@ sudo npm install --global yarn
### Install postgresql requirements ### Install postgresql requirements
```shell ```shell
sudo apt install libpq-dev postgresql sudo apt install -y libpq-dev postgresql
``` ```
### Install LDAP requirements ### Install LDAP requirements
```shell ```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 ### Install project requirements
@@ -65,12 +70,13 @@ sudo apt install libsasl2-dev python-dev libldap2-dev libssl-dev
Using binaries from the virtual env: Using binaries from the virtual env:
```shell ```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 You will also need to install front end requirements and build them. For this navigate to the `./vue` folder and run
```shell ```shell
cd ./vue
yarn install yarn install
yarn build 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 --Grant superuser right to your new user, it will be removed later
ALTER USER djangouser WITH SUPERUSER; ALTER USER djangouser WITH SUPERUSER;
--exit Postgres Environment
exit
``` ```
Download the `.env` configuration file and **edit it accordingly**. 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: 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_HOST`: probably 127.0.0.1.
- `POSTGRES_PASSWORD`: the password we set earlier when setting up djangodb. - `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. - `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 `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 ## 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 *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 ### 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). In order to update the application you will need to run the following commands (probably best to put them into a small script).
```shell ```shell
# change directory
cd /var/www/recipes
# Update source files # Update source files
git pull git pull
# load envirtonment variables # load envirtonment variables