Django-hosting » History » Version 10
Nico Schottelius, 04/08/2016 11:39 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 | # Restart uwsgi to restart your app |
||
| 10 | # Go to http://your-hostname/ and enjoy! |
||
| 11 | 1 | Nico Schottelius | |
| 12 | |||
| 13 | 8 | Nico Schottelius | h2. Configure your app |
| 14 | |||
| 15 | h3. WSGI |
||
| 16 | |||
| 17 | * Ensure that there is _projectname_/wsgi.py in your project root |
||
| 18 | |||
| 19 | h3. Database |
||
| 20 | |||
| 21 | Add the following to your settings.py: |
||
| 22 | |||
| 23 | <pre> |
||
| 24 | DATABASES = { |
||
| 25 | 'default': { |
||
| 26 | 'ENGINE': 'django.db.backends.postgresql_psycopg2', |
||
| 27 | 'NAME': 'app', |
||
| 28 | } |
||
| 29 | } |
||
| 30 | </pre> |
||
| 31 | 4 | Nico Schottelius | |
| 32 | |||
| 33 | 10 | Nico Schottelius | h2. Deploy |
| 34 | 1 | Nico Schottelius | |
| 35 | 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): |
| 36 | 1 | Nico Schottelius | |
| 37 | 10 | Nico Schottelius | <pre> |
| 38 | ssh app@MYHOSTNAME |
||
| 39 | </pre> |
||
| 40 | 4 | Nico Schottelius | |
| 41 | 1 | Nico Schottelius | |
| 42 | 10 | Nico Schottelius | * Deploy / update your app into the folder *~app/app* (that is the app folder in the home of the user app) |
| 43 | * We recommended to use git to deploy it |
||
| 44 | * Restart the app to load the new code of your app |
||
| 45 | |||
| 46 | h2. Restarting the app |
||
| 47 | 2 | Nico Schottelius | |
| 48 | * *sudo systemctl restart uwsgi* |
||
| 49 | |||
| 50 | |||
| 51 | 1 | Nico Schottelius | h3. Viewing logfiles |
| 52 | 4 | Nico Schottelius | |
| 53 | * nginx access log: *tail -F /var/log/nginx/access.log* |
||
| 54 | 7 | Nico Schottelius | * nginx error log: *tail -F /var/log/nginx/error.log* |
| 55 | 6 | Nico Schottelius | * uwsgi log: *tail -F /var/log/uwsgi/app/app.log* |
| 56 | 4 | Nico Schottelius | |
| 57 | 1 | Nico Schottelius | |
| 58 | |||
| 59 | |||
| 60 | h2. Description of the stack |
||
| 61 | |||
| 62 | h3. Technologies |
||
| 63 | |||
| 64 | * Debian 8 |
||
| 65 | * nginx |
||
| 66 | * PostgreSQL |
||
| 67 | 3 | Nico Schottelius | * uwsgi |
| 68 | |||
| 69 | h3. Configuration |
||
| 70 | |||
| 71 | * user "app" |
||
| 72 | ** in group "adm" (to view logfiles) |
||
| 73 | * PostgreSQL with |
||
| 74 | ** database "app" |
||
| 75 | ** Listens only on localhost / socket (no remote connections) |
||
| 76 | 1 | Nico Schottelius | ** |