diff options
| author | jvoisin | 2019-02-23 13:27:33 +0100 |
|---|---|---|
| committer | jvoisin | 2019-02-23 13:27:33 +0100 |
| commit | 1b0333fdd5175d6a45d1929218e0aac3db884139 (patch) | |
| tree | 2438036e7c3c9159ecd80c06aa1d8fd336509819 | |
| parent | 489fc7f2b5ef3d4be0f74e405a4200c6ffc12fc3 (diff) | |
Improve the deployment configuration
| -rw-r--r-- | README.md | 55 | ||||
| -rw-r--r-- | config/apache2.config | 6 | ||||
| -rw-r--r-- | config/nginx.config | 14 | ||||
| -rw-r--r-- | config/uwsgi.config | 19 |
4 files changed, 48 insertions, 46 deletions
| @@ -30,59 +30,22 @@ Pin-Priority: 10 | |||
| 30 | Then: | 30 | Then: |
| 31 | 31 | ||
| 32 | ``` | 32 | ``` |
| 33 | # apt install git nginx-light uwsgi uwsgi-plugin-python3 mat2 --no-install-recommends | 33 | # apt install uwsgi uwsgi-plugin-python3 git mat2 |
| 34 | # apt install nginx-light # if you prefer nginx | ||
| 35 | # apt install apache2 libapache2-mod-proxy-uwsgi # if you prefer Apache2 | ||
| 34 | # cd /var/www/ | 36 | # cd /var/www/ |
| 35 | # git clone https://0xacab.org/jvoisin/mat2-web.git | 37 | # git clone https://0xacab.org/jvoisin/mat2-web.git |
| 36 | # mkdir ./mat2-web/uploads/ | 38 | # mkdir ./mat2-web/uploads/ |
| 37 | # chown -R www-data:www-data ./mat2-web | 39 | # chown -R www-data:www-data ./mat2-web |
| 38 | ``` | 40 | ``` |
| 39 | 41 | ||
| 40 | Since uwsgi isn't fun to configure, feel free to slap this into your | 42 | Since uwsgi isn't fun to configure, feel free to copy [this file](https://0xacab.org/jvoisin/mat2-web/tree/master/config/uwsgi.config) |
| 41 | `/etc/uwsgi/apps-enabled/mat2-web.ini`: | 43 | to `/etc/uwsgi/apps-enabled/mat2-web.ini` and [this one](https://0xacab.org/jvoisin/mat2-web/tree/master/config/nginx.config) |
| 44 | to `/etc/nginx/site-enabled/mat2-web`. | ||
| 42 | 45 | ||
| 43 | ```ini | 46 | Nginx is the recommended web engine, but you can also use Apache if you prefer, |
| 44 | [uwsgi] | 47 | by copying [this file](https://0xacab.org/jvoisin/mat2-web/tree/master/config/apache2.config) |
| 45 | module=main | 48 | to your `/etc/apache2/sites-enabled/mat2-web` file. |
| 46 | chdir = /var/www/mat2-web/ | ||
| 47 | callable = app | ||
| 48 | wsgi-file = main.py | ||
| 49 | master = true | ||
| 50 | workers = 1 | ||
| 51 | |||
| 52 | uid = www-data | ||
| 53 | gid = www-data | ||
| 54 | |||
| 55 | # kill stalled processes | ||
| 56 | harakiri = 30 | ||
| 57 | die-on-term = true | ||
| 58 | |||
| 59 | socket = mat2-web.sock | ||
| 60 | chmod-socket = 774 | ||
| 61 | plugins = python3 | ||
| 62 | ``` | ||
| 63 | |||
| 64 | and this into your `/etc/nginx/site-enabled/mat2-web`: | ||
| 65 | |||
| 66 | ```nginx | ||
| 67 | location / { try_files $uri @yourapplication; } | ||
| 68 | location @yourapplication { | ||
| 69 | include uwsgi_params; | ||
| 70 | uwsgi_pass unix:/var/www/mat2-web/mat2-web.sock; | ||
| 71 | } | ||
| 72 | ``` | ||
| 73 | |||
| 74 | Nginx is the recommended web engine, but you can also use Apache if you prefer: | ||
| 75 | |||
| 76 | ``` | ||
| 77 | apt install apache2 libapache2-mod-proxy-uwsgi | ||
| 78 | ``` | ||
| 79 | |||
| 80 | and add this to your `/etc/apache2/sites-enabled/mat2-web` in the `virtualhost` block: | ||
| 81 | |||
| 82 | ```Apache | ||
| 83 | ProxyPass / unix:/var/www/mat2-web/mat2-web.sock|uwsgi://localhost/ | ||
| 84 | |||
| 85 | ``` | ||
| 86 | 49 | ||
| 87 | Finally, restart `uwsgi` and your web server: | 50 | Finally, restart `uwsgi` and your web server: |
| 88 | 51 | ||
diff --git a/config/apache2.config b/config/apache2.config new file mode 100644 index 0000000..2489609 --- /dev/null +++ b/config/apache2.config | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | Listen 80 | ||
| 2 | <VirtualHost *:80> | ||
| 3 | DocumentRoot "/var/www/mat2-web/" | ||
| 4 | |||
| 5 | ProxyPass / unix:/var/www/mat2-web/mat2-web.sock|uwsgi://localhost/ | ||
| 6 | </VirtualHost> | ||
diff --git a/config/nginx.config b/config/nginx.config new file mode 100644 index 0000000..b519ee7 --- /dev/null +++ b/config/nginx.config | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | server { | ||
| 2 | server_name _; | ||
| 3 | listen 80 default_server; | ||
| 4 | listen [::]:80 default_server; | ||
| 5 | client_max_body_size 20M; | ||
| 6 | |||
| 7 | root /var/www/mat2-web; | ||
| 8 | |||
| 9 | location / { try_files $uri @yourapplication; } | ||
| 10 | location @yourapplication { | ||
| 11 | include uwsgi_params; | ||
| 12 | uwsgi_pass unix:/var/www/mat2-web/mat2-web.sock; | ||
| 13 | } | ||
| 14 | } | ||
diff --git a/config/uwsgi.config b/config/uwsgi.config new file mode 100644 index 0000000..7108d33 --- /dev/null +++ b/config/uwsgi.config | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | [uwsgi] | ||
| 2 | module=main | ||
| 3 | chdir = /var/www/mat2-web/ | ||
| 4 | callable = app | ||
| 5 | wsgi-file = main.py | ||
| 6 | master = true | ||
| 7 | workers = 1 | ||
| 8 | |||
| 9 | uid = www-data | ||
| 10 | gid = www-data | ||
| 11 | |||
| 12 | # kill stalled processes | ||
| 13 | harakiri = 30 | ||
| 14 | die-on-term = true | ||
| 15 | |||
| 16 | socket = mat2-web.sock | ||
| 17 | chmod-socket = 774 | ||
| 18 | plugins = python3 | ||
| 19 | |||
