To connect ubuntu server

ssh -i keys/owaV2.pem [email protected]

Update server packages

sudo apt-get update
apt upgrade -y

Install Python Virtual Enviornment

sudo apt-get install python3-venv

Create Virtual env

python3 -m venv venv

Install packages - add gunicorn

Run Gunicorn - checking

gunicorn -b 0.0.0.0:8000 app(filename):app(flaskappname)

Create gunicorn/nginx service

sudo nano /etc/systemd/system/helloowa.service

[Unit]
Description=Hello OWA
After=network.target
[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/helloowa
ExecStart=/home/ubuntu/venv/bin/gunicorn -b localhost:8000 app:app
Restart=always
[Install]
WantedBy=multi-user.target

Restart service

sudo systemctl daemon-reload

Start and enable service

sudo systemctl start helloowa
sudo systemctl enable helloowa

Install nginx and start & enable

sudo apt-get install nginx

sudo systemctl start nginx
sudo systemctl enable nginx