Application Tier

  1. First, we need zip code then copy to EC2 Public

EC2

  1. Check received or not

EC2

  1. Copy backend.zip to EC2 Private - Application

EC2

  1. SSH to EC2 Private - Application and check EC2

  2. Install unzip then unzip backend.zip

EC2 EC2

  1. Create user backend, create directory /projects and move folder backend to

EC2

  1. chown, chmod folder backend, check

EC2

  1. Install python, pip, venv

EC2 EC2 EC2

  1. Create virtualenv - environment for python to run the project, then activate this virtual environment

EC2

  1. Install project’s dependencies
pip install -r requirements.txt

EC2

  1. Change ip database to Database tier’s ip

EC2 EC2

  1. Run project, error with database

EC2

  1. Change Security Group Private Subnet, add rule TCP port 27017 of MongoDB

EC2

  1. Run project again, successful

EC2

  1. Then, we use nginx as revert proxy for backend, install

EC2

  1. Create a new file, name as fastapi_nginx in the direct : /etc/nginx/sites-enabled/ , has this content :

EC2

  1. Checking syntax of nginx and restart

EC2

  1. Restart project, now nginx is running as revert proxy, forward request from port 80 to port 8000.

EC2