forked from data-geeks/Quiz-Mania-Project1_V2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ec2-Django.txt
83 lines (60 loc) · 1.89 KB
/
ec2-Django.txt
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
sudo apt-get update
sudo apt-get install python3-pip python-dev nginx git
Y
sudo apt-get update
sudo pip3 install virtualenv
git clone https://github.com/mruanova/zillow.git
cd Quiz-Mania-Project1_V2/QuizMania
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
pip3 install django bcrypt django-extensions
pip3 install gunicorn
cd QuizMania
sudo vim settings.py
# Inside settings.py modify these lines allowed host public IP address I for INSERT
i
ALLOWED_HOSTS = ['54.80.215.41']
# add the line below to the bottom of the file
STATIC_ROOT = os.path.join(BASE_DIR, "static/")
Save your changes and quit. ESC :wq
cd ..
python3 manage.py collectstatic
gunicorn --bind 0.0.0.0:8000 QuizMania.wsgi:application
ctrl+c
sudo vim /etc/systemd/system/gunicorn.service
i
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/Quiz-Mania-Project1_V2/QuizMania
ExecStart=/home/ubuntu/Quiz-Mania-Project1_V2/QuizMania/venv/bin/gunicorn --workers 3 --bind unix:/home/ubuntu/Quiz-Mania-Project1_V2/QuizMania/QuizMania.sock QuizMania.wsgi:application
[Install]
WantedBy=multi-user.target
ESC :wq
sudo systemctl daemon-reload
sudo systemctl start gunicorn
sudo systemctl enable gunicorn
sudo vim /etc/nginx/sites-available/QuizMania
i
server {
listen 80;
server_name 18.208.168.19;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/ubuntu/Quiz-Mania-Project1_V2/QuizMania;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/ubuntu/Quiz-Mania-Project1_V2/QuizMania/QuizMania.sock;
}
}
ESC :wq
sudo ln -s /etc/nginx/sites-available/QuizMania /etc/nginx/sites-enabled
sudo nginx -t
sudo rm /etc/nginx/sites-enabled/default
sudo service nginx restart
http://54.80.215.41