You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/post/deploying-wagtail.mdx
+5-7Lines changed: 5 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Ok, let's get started. Oh, before that, I'll make some disclaimer. Because this
11
11
12
12
First, we need to prepare our system. For this, I use cloud VPS. After investigated some of cloud providers out there, I chose DigitalOcean because it's so simple and so cheap. For the basic tier, you'll be charged just 5 bucks a month. Granted there are more powerful cloud provider out there, with Amazon AWS being the prime example. Unfortunately it doesn't have the simplicity DigitalOcean has. AWS's pricing is so convoluted and sophisticated I feel, and also it's directed to power user like devops guys.
13
13
14
-
To prepare the production environment, I'm strongly urge you to follow this guide: <https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-uwsgi-and-nginx-on-ubuntu-14-04>.
14
+
To prepare the production environment, I'm strongly urge you to follow this guide: https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-uwsgi-and-nginx-on-ubuntu-14-04.
15
15
16
16
When everything (nginx, uwsgi) is ready, we can begin to really deploy our blog in the cloud. Here's the workflow that I use whenever I made some code change to this blog:
17
17
@@ -31,17 +31,15 @@ For number 7, we need to restart uwsgi because when uwsgi started, it will "comp
31
31
We already know that Django has multiple setting files: base.py, dev.py, and production.py. In our production environment we surely want to use production.py file to override our base.py. To make our life easier, we can put a script to automatically pick which setting file we have to use depending on what environment we are in. To do this, we'll edit our `__init__.py` inside the settings directory.
32
32
33
33
```python
34
-
35
34
# settings/**init**.py
36
-
37
35
import os
38
36
39
37
ENV= os.getenv('MYBLOG_ENV', 'dev')
40
38
41
39
ifENV=='dev':
42
-
from .dev import*
40
+
from .dev import*
43
41
elifENV=='prod':
44
-
from .production import*
42
+
from .production import*
45
43
```
46
44
47
45
First, we find an environment variable named 'MYBLOG_ENV' in our operating system, with 'dev' as the default value. If that environment variable value is 'dev', we use dev.py, otherwise we use production.py. As simple as that. To create the environment variable, there are two ways, first by add it directly to the system, or put it in uwsgi. I will go with the second option because, just like the use of virtualenv, it aligns with our spirit of software environment isolation. This this line to your uwsgi config file, and restart uwsgi to apply the change:
@@ -56,8 +54,8 @@ Now, our Wagtail app in the production server will always use production.py, and
56
54
57
55
I spent a lot of time trying to figure out how to deploy this blog. I'd say most of my time creating this blog is here, in the deployment stage, debugging things that didn't work. Here's the list of some problems that I encountered while trying to make this blog up and running:
58
56
59
-
_Error 400:_ Check your setting, make sure you've added your domain/IP in "allowed*sites" field
60
-
\_Error 500:* Don't forget to do all of the above steps! I encountered this problem because I didn't compress my static files
57
+
_Error 400:_ Check your setting, make sure you've added your domain/IP in `allowed_sites` field
58
+
_Error 500:_ Don't forget to do all of the above steps! I encountered this problem because I didn't compress my static files
61
59
Cannot upload image: The root cause is you don't have libjpeg and libpng in your machine
0 commit comments