Django-hosting » History » Version 14
Nico Schottelius, 04/08/2016 01:08 PM
1 | 1 | Nico Schottelius | h1. django-hosting.ch by ungleich |
---|---|---|---|
2 | |||
3 | 9 | Nico Schottelius | {{toc}} |
4 | |||
5 | 1 | Nico Schottelius | h2. How to use |
6 | |||
7 | 8 | Nico Schottelius | # Configure your app |
8 | # Deploy your app |
||
9 | 11 | Nico Schottelius | # Install python requirements into the pyvenv |
10 | 8 | Nico Schottelius | # Restart uwsgi to restart your app |
11 | # Go to http://your-hostname/ and enjoy! |
||
12 | 1 | Nico Schottelius | |
13 | |||
14 | 8 | Nico Schottelius | h2. Configure your app |
15 | |||
16 | h3. WSGI |
||
17 | |||
18 | * Ensure that there is _projectname_/wsgi.py in your project root |
||
19 | |||
20 | h3. Database |
||
21 | |||
22 | Add the following to your settings.py: |
||
23 | |||
24 | <pre> |
||
25 | DATABASES = { |
||
26 | 'default': { |
||
27 | 'ENGINE': 'django.db.backends.postgresql_psycopg2', |
||
28 | 'NAME': 'app', |
||
29 | } |
||
30 | } |
||
31 | </pre> |
||
32 | 4 | Nico Schottelius | |
33 | 14 | Nico Schottelius | h3. Static and media files |
34 | |||
35 | Static files should be place in */home/app/app/static* and media files in */home/app/app/media*. |
||
36 | |||
37 | |||
38 | 4 | Nico Schottelius | |
39 | 10 | Nico Schottelius | h2. Deploy |
40 | 1 | Nico Schottelius | |
41 | 10 | Nico Schottelius | You can login to your VM as user *app* (for the django app) and *root* (in case you need to change settings): |
42 | 1 | Nico Schottelius | |
43 | 10 | Nico Schottelius | <pre> |
44 | ssh app@MYHOSTNAME |
||
45 | </pre> |
||
46 | 4 | Nico Schottelius | |
47 | 1 | Nico Schottelius | |
48 | 10 | Nico Schottelius | * Deploy / update your app into the folder *~app/app* (that is the app folder in the home of the user app) |
49 | 1 | Nico Schottelius | * We recommended to use git to deploy it |
50 | 11 | Nico Schottelius | |
51 | h2. Install python requirements into the pyvenv |
||
52 | |||
53 | 13 | Nico Schottelius | Pyvenv has been installed to *~app/pyvenv* for you. |
54 | Required packages for the hosting like PostgreSQL support and uwsgi support have already been placed. |
||
55 | |||
56 | You need to use pyvenv found in *~app/pyvenv*, as uwsgi loads this pyvenv before loading your app. |
||
57 | |||
58 | To install your requirements use: |
||
59 | 11 | Nico Schottelius | |
60 | <pre> |
||
61 | . ~/pyvenv/bin/activate |
||
62 | pip install ... |
||
63 | </pre> |
||
64 | 10 | Nico Schottelius | |
65 | h2. Restarting the app |
||
66 | 2 | Nico Schottelius | |
67 | * *sudo systemctl restart uwsgi* |
||
68 | |||
69 | |||
70 | 1 | Nico Schottelius | h3. Viewing logfiles |
71 | 4 | Nico Schottelius | |
72 | * nginx access log: *tail -F /var/log/nginx/access.log* |
||
73 | 7 | Nico Schottelius | * nginx error log: *tail -F /var/log/nginx/error.log* |
74 | 6 | Nico Schottelius | * uwsgi log: *tail -F /var/log/uwsgi/app/app.log* |
75 | 4 | Nico Schottelius | |
76 | 1 | Nico Schottelius | |
77 | |||
78 | |||
79 | h2. Description of the stack |
||
80 | |||
81 | h3. Technologies |
||
82 | |||
83 | * Debian 8 |
||
84 | * nginx |
||
85 | * PostgreSQL |
||
86 | 3 | Nico Schottelius | * uwsgi |
87 | |||
88 | h3. Configuration |
||
89 | |||
90 | * user "app" |
||
91 | ** in group "adm" (to view logfiles) |
||
92 | * PostgreSQL with |
||
93 | 1 | Nico Schottelius | ** database "app" |
94 | 3 | Nico Schottelius | ** Listens only on localhost / socket (no remote connections) |
95 | 12 | Nico Schottelius | ** |