forked from dreamland-mud/dreamland_web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
INSTALL
87 lines (73 loc) · 2 KB
/
INSTALL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
=== Running existing Django project ===
virtualenv django-env
. django-env/bin/activate
pip install django
pip install djangorestframework
pip install django-filter
./manage.py migrate
./manage.py createsuperuser
./manage.py runserver [0.0.0.0:8000]
=== Starting Django project from scratch ===
virtualenv django-env
. django-env/bin/activate
pip install django
pip install djangorestframework
pip install django-filter
django-admin startproject website
django-admin startapp searcher
cd website
export PYTHONPATH=..
# edit settings.py, add 'searcher', restframework, django_filters to INSTALLED_APPS
./manage.py migrate
./manage.py createsuperuser
./manage.py runserver [0.0.0.0:port]
# edit models, then run
./manage.py makemigration
./manage.py migrate
# edit api_urls, urls
# edit admin.py to register models
=== Adding new command ===
create management/commands/yourcmd.py
create __init__.py in all empty folders
=== Adding GZIP middleware ===
MIDDLEWARE_CLASSES = (
'django.middleware.gzip.GZipMiddleware',
...
=== Adding CORS support ===
pip install django-cors-headers
INSTALLED_APPS = (
...
'pipeline',
'corsheaders'
)
MIDDLEWARE_CLASSES = (
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
...
)
=== Configuring SSL for dev server ===
apt-get install stunnel
mkdir stunnel
cd stunnel
# Generate keys: openssl option
#openssl genrsa 1024 > stunnel.key
#openssl req -new -x509 -nodes -sha1 -days 365 -key stunnel.key > stunnel.cert
# Generate keys: existing cert option
copy /path/to/letsencrypt/cert.pem and privkey.pem
cat stunnel.key stunnel.cert > stunnel.pem
cat < EOM > dev_https
pid=
cert = stunnel/stunnel.pem
sslVersion = all
foreground = yes
output = stunnel.log
[https]
accept=<sslport>
connect=<port1>
TIMEOUTclose=1
cd ..
stunnel4 stunnel/dev_https &
python manage.py runserver&
HTTPS=1 python manage.py runserver <port1>
=== Updating SSL certificates for new domains ===
certbot certonly --expand -d <comma-separated list of domain names>