Deployment on Heroku, AWS, and DigitalOcean
Deployment on Heroku
Initial Setup
- Create a new project on Heroku:
-
Create an application on Heroku and select the database (PostgreSQL recommended).
-
Install Heroku CLI:
- Ensure you have
heroku-cli
installed and authenticated on your local machine.
Environment Preparation
- Create a
Procfile
: - This file tells Heroku how to run your application:
web: gunicorn nombre_del_proyecto.wsgi
- Install dependencies:
- Include Gunicorn and any other dependencies in your
requirements.txt
.
Deployment
- Use the following command to deploy your application:
git push heroku main
- After deployment, run the database migrations:
heroku run python manage.py migrate
Deployment on AWS
Elastic Beanstalk Setup
- Create a new application:
-
Log in to the AWS Management Console and create a new application in Elastic Beanstalk.
-
Choose the platform:
- Select the Python platform and configure the instances according to your needs.
Database Configuration
- Use Amazon RDS to manage the database. Ensure you select PostgreSQL or MySQL and configure it correctly.
Deployment
- Use the AWS CLI to package and deploy your application:
eb create nombre_de_tu_entorno
- Once the environment is created, run migrations if necessary:
eb ssh
python manage.py migrate
Deployment on DigitalOcean
Droplet Setup
- Create a new Droplet:
- Select an Ubuntu image and ensure it has internet access.
Dependency Installation
- Connect to the server and run the following commands to install Gunicorn and Nginx:
sudo apt update
sudo apt install nginx
sudo apt install python3-gunicorn
Deployment
- Upload your code to the server using Git or SCP and configure Gunicorn and Nginx to serve your application.