ec2에 바로 nginx로 구동하기
#!/bin/bash
sed 's/PasswordAuthentication no/PasswordAuthentication yes/' -i /etc/ssh/sshd_config
echo "1234" | passwd --stdin ec2-user
systemctl restart sshd
mkdir /projects
mkdir /venvs
python3 -m venv /venvs/my
amazon-linux-extras install nginx1.12
aws s3 cp s3://skills-codebuild-bucket-2/limtest.zip /
unzip /limtest.zip -d /projects/
. /venvs/my/bin/activate
pip3 install djangorestframework
pip3 install django==2.1.7
pip3 install gunicorn
touch /etc/systemd/system/my1.service
touch /venvs/mysite.env
echo "DJANGO_SETTINGS_MODULE=fastcampus.settings" > /venvs/mysite.env
echo -e "[Unit]\nDescription=gunicorn daemon\nAfter=network.target\n\n[Service]\nUser=root\nGroup=root\nWorkingDirectory=/projects\nEnvironmentFile=/venvs/mysite.env\nExecStart=/venvs/my/bin/gunicorn --workers 2 --bind 0:8000 fastcampus.wsgi:application\n\n[Install]\nWantedBy=multi-user.target" > /etc/systemd/system/my1.service
sed "38,81d" -i /etc/nginx/nginx.conf
sed -e '37 i\ server {\n listen 80;\n server_name localhost;\n location = /favicon.ico { access_log off; log_not_found off; }\n\n location / {\n proxy_pass http://localhost:8000;\n }\n }' -i /etc/nginx/nginx.conf
systemctl start my1.service
systemctl start nginx.service