Project

General

Profile

Django-hosting » History » Version 11

Nico Schottelius, 04/08/2016 11:45 AM

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
34 10 Nico Schottelius
h2. Deploy
35 1 Nico Schottelius
36 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):
37 1 Nico Schottelius
38 10 Nico Schottelius
<pre>
39
ssh app@MYHOSTNAME
40
</pre>
41 4 Nico Schottelius
42 1 Nico Schottelius
43 10 Nico Schottelius
* Deploy / update your app into the folder *~app/app* (that is the app folder in the home of the user app)
44 1 Nico Schottelius
* We recommended to use git to deploy it
45 11 Nico Schottelius
46
h2. Install python requirements into the pyvenv
47
48
Pyvenv has been installed and you need to use pyvenv found in *~/pyvenv*:
49
50
<pre>
51
. ~/pyvenv/bin/activate
52
pip install ...
53
</pre>
54
55 10 Nico Schottelius
56
h2. Restarting the app
57 2 Nico Schottelius
58
* *sudo systemctl restart uwsgi*
59
60
61 1 Nico Schottelius
h3. Viewing logfiles
62 4 Nico Schottelius
63
* nginx access log: *tail -F /var/log/nginx/access.log*
64 7 Nico Schottelius
* nginx error log: *tail -F /var/log/nginx/error.log*
65 6 Nico Schottelius
* uwsgi log: *tail -F /var/log/uwsgi/app/app.log*
66 4 Nico Schottelius
67 1 Nico Schottelius
68
69
70
h2. Description of the stack
71
72
h3. Technologies
73
74
* Debian 8
75
* nginx
76
* PostgreSQL
77 3 Nico Schottelius
* uwsgi
78
79
h3. Configuration
80
81
* user "app"
82
** in group "adm" (to view logfiles)
83
* PostgreSQL with
84
** database "app"
85
** Listens only on localhost / socket (no remote connections)
86 1 Nico Schottelius
**