Update manual setup
I just went through a manual install on DietPi / Debian Unstable, and found that the manual needed some improving, this method works, whereas following the original manual was not a success for me. The only line I would say I am unsure about is this one: "Give the user permissions: `chown -R recipes:www-data /var/www/recipes`" As I am not sure whether these permissions are necessary for this to work. Hope this is useful, let me know if I can make further improvements.
This commit is contained in:
parent
da57e656eb
commit
576c62b8a1
@ -7,16 +7,30 @@ These intructions are inspired from a standard django/gunicorn/postgresql instru
|
|||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
*Optional*: create a virtual env and activate it
|
Setup user: `sudo useradd recipes`
|
||||||
|
|
||||||
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`
|
||||||
|
|
||||||
Install postgresql requirements: `sudo apt install libpq-dev postgresql`
|
Move it to the `/var/www` directory: `mv recipes /var/www`
|
||||||
Install project requirements: `pip3.9 install -r requirements.txt`
|
|
||||||
|
Give the user permissions: `chown -R recipes:www-data /var/www/recipes`
|
||||||
|
|
||||||
|
Create virtual env: `python3.9 -m venv /var/www/recipes`
|
||||||
|
|
||||||
|
### Install postgresql requirements
|
||||||
|
|
||||||
|
`sudo apt install libpq-dev postgresql`
|
||||||
|
|
||||||
|
###Install project requirements
|
||||||
|
|
||||||
|
Using binaries from the virtual env:
|
||||||
|
|
||||||
|
`/var/www/recipes/bin/pip3.9 install -r requirements.txt`
|
||||||
|
|
||||||
|
|
||||||
## Setup postgresql
|
## Setup postgresql
|
||||||
|
|
||||||
Run `sudo -u postgres psql`
|
`sudo -u postgres psql`
|
||||||
|
|
||||||
In the psql console:
|
In the psql console:
|
||||||
|
|
||||||
@ -37,12 +51,12 @@ ALTER USER djangouser WITH SUPERUSER;
|
|||||||
|
|
||||||
Download the `.env` configuration file and **edit it accordingly**.
|
Download the `.env` configuration file and **edit it accordingly**.
|
||||||
```shell
|
```shell
|
||||||
wget https://raw.githubusercontent.com/vabene1111/recipes/develop/.env.template -O .env
|
wget https://raw.githubusercontent.com/vabene1111/recipes/develop/.env.template -O /var/www/recipes/.env
|
||||||
```
|
```
|
||||||
|
|
||||||
## Initialize the application
|
## Initialize the application
|
||||||
|
|
||||||
Execute `export $(cat .env |grep "^[^#]" | xargs)` to load variables from `.env`
|
Execute `export $(cat /var/www/recipes/.env |grep "^[^#]" | xargs)` to load variables from `/var/www/recipes/.env`
|
||||||
|
|
||||||
Execute `/python3.9 manage.py migrate`
|
Execute `/python3.9 manage.py migrate`
|
||||||
|
|
||||||
@ -67,10 +81,11 @@ After=network.target
|
|||||||
Type=simple
|
Type=simple
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=3
|
RestartSec=3
|
||||||
|
User=recipes
|
||||||
Group=www-data
|
Group=www-data
|
||||||
WorkingDirectory=/media/data/recipes
|
WorkingDirectory=/var/www/recipes
|
||||||
EnvironmentFile=/media/data/recipes/.env
|
EnvironmentFile=/var/www/recipes/.env
|
||||||
ExecStart=/opt/.pyenv/versions/3.9/bin/gunicorn --error-logfile /tmp/gunicorn_err.log --log-level debug --capture-output --bind unix:/media/data/recipes/recipes.sock recipes.wsgi:application
|
ExecStart=/var/www/recipes/bin/gunicorn --error-logfile /tmp/gunicorn_err.log --log-level debug --capture-output --bind unix:/var/www/recipes/recipes.sock recipes.wsgi:application
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
@ -96,15 +111,15 @@ server {
|
|||||||
|
|
||||||
# serve media files
|
# serve media files
|
||||||
location /static {
|
location /static {
|
||||||
alias /media/data/recipes/staticfiles;
|
alias /var/www/recipes/staticfiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /media {
|
location /media {
|
||||||
alias /media/data/recipes/mediafiles;
|
alias /var/www/recipes/mediafiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://unix:/media/data/recipes/recipes.sock;
|
proxy_pass http://unix:/var/www/recipes/recipes.sock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user