Create a WebGIS with Django and React and Deploy to AWS EC2
This will be a simple tutorial for you who would like to create a WebGIS, the focus is to explain how to deploy using Apache on AWS, and with this basic configuration, you can start your projects.
Let’s start with creating a simple structure. You will need to have Python, node, and npm already installed on your computer. There will be two main folders, the “backend” and the “frontend”.
Inside the backend folder run the following commands (with Ubuntu 22.04):
django-admin startproject backend
cd backend
python3 -m venv venv
source venv/bin/activate
pip install django djangorestframework djangorestframework-simplejwt
python manage.py startapp main
This should be enough to start your backend (later, you will need to handle environment variables to remove things like your SECRET_KEY from the source code). Check a “settings.py” example:
import os
from datetime import timedelta
from pathlib import Path
from decouple import config
BASE_DIR = Path(__file__).resolve().parent.parent
SECRET_KEY = config('SECRET_KEY', default='mydefaultsecretkey')
DEBUG = config('DEBUG', default=False, cast=bool)
GDAL_LIBRARY_PATH = config('GDAL_LIBRARY_PATH', default='') # for windows
GEOS_LIBRARY_PATH = config('GEOS_LIBRARY_PATH', default='') # for windows…