
Quick overview about what you will learn in this section of the course:
Simplest architecture
Complex architecture
Components involved
Component options
My recommendations
You will need a computer to install Linux on. In this lecture I will explain some of your options for development and production environments. Check the downloadable materials for this lecture to get a link worth $100 of credit on Digital Ocean which you can use to rent a virtual machine and follow along with the rest of the course.
Since we are deploying to Linux, you'll need a GNU/Linux machine. What you learn in this course will apply to almost any Linux distribution with minimal changes. In this lecture I will discuss some of the Linux distributions that I would recommend and some of the pros and cons of each.
In this lecture I will explain what the WSGI server is and it's role. We'll also look at what options are available for WSGI servers and which ones I recommend.
Learn about the web server's role in a Django deployment and what options are available.
Learn where the database fits into the architecture and what database options are available. I will also give my recommendations.
Let's recap everything we've talked about in this architecture section and go over the important pieces you should understand at this point.
Rather than running all the components on a single machine, it is possible to separate the components and architect the solution in a variety of ways. I will illustrate different variations of the architecture and explain why you might choose each variation depending on where you need to scale your project.
Let's walk through creating a new virtual machine on Digital Ocean with Debian and logging in. If you have your own Linux machine already, you can skip this section, but I recommend a fresh Debian install.
See the attached text file for a link with the $100 promo on Digital Ocean.
Let's begin by creating a Python virtual environment to keep the project dependencies isolated from system packages and talk about why it's a good idea.
Let's quickly create a simple hello world template project with django-admin so we have something to work with and you can follow along if you don't have your own project.
In this lecture we'll look at how to setup the ~/.ssh/config file to allow specific SSH keys for your git clone.
In ths lecture we'll clone the repository from GitHub and put it in the production location on the disk. We'll also look at setting proper permissions and talk about best practices with manging settings files.
Learn about security best practices and dealing with multiple settings files for different environments.
Ensure the Django settings are configured for PostgreSQL and install the Python dependency psycopg2-binary.
Learn how to install and setup the PostgreSQL database for use with Django. We will look at
Installing PostgreSQL
Logging in as admin
Creating a new database
Creating a new database user and granting privileges
Reviewing authentication mechanisms
Here I will show you how to install gunicorn and use it to run your WSGI application from the command-line.
Now that you understand how to execute gunicorn to run your WSGI application, let's create a systemd service file to ensure the gunicorn server is always running.
Let's install the Nginx web server/reverse proxy and test it out to make sure it works.
In this lecture, learn about:
The difference between the STATIC and MEDIA directories in Django
How to configure STATIC_URL, STATIC_ROOT, MEDIA_URL, and MEDIA_ROOT in Django settings.py
How to configure permissions for the directories
In this part, we'll get back to the Nginx configuration and setup our virtualhost with:
Custom Nginx config file for the project
Port and hostname listener
Serving static files
Reverse proxy WSGI requests
Let's complete the Nginx configuration by adding SSL encryption to our virtual host.
Install certbot
Get signed SSL certificate from LetsEncrypt.org
Update Nginx configuration to serve encrypted HTTPS
Setup a redirect so all HTTP traffic goes to HTTPS automatically
Let's quickly have an overview of:
Why a dev site is useful
How we can protect the dev site
What options we have
Additional security measures you can take
In this lecture we'll walk through the steps to setup a development/staging site on a different port. It will be password protected and use self-signed certificates.
Learn about the different backup options for things like:
Options for writing the backup script
Options for triggering backups
Remote backup options
Let's write the Bash shell script to perform the backup and also setup the cron job to trigger it to run periodically.
Learn about the different options for scripting and triggering the updates.
Let's setup a cron job to automatically renew the SSL certificate.
Let's write the Bash shell script that will perform project updates.
I will walk you through all the major components of deploying Django.
Learn about the architecture of a deployment and how the different pieces fit together. You will understand the differences and similarities between different options for:
Linux distribution (Debian vs Ubuntu vs CentOS vs Fedora)
Web server (Nginx vs Apache2)
Database server (SQLite vs MySQL vs MariaDB vs PostgreSQL)
WSGI server (uWSGI vs gunicorn vs waitress)
SSL certificates (self-signed vs LetsEncrypt)
The first portion of the course will talk about the architecture and the role of each component. I will also discuss alternative architectures and things to consider when planning. I'll talk about the different options and which ones I recommend for various situations. The second portion of the course will be an actual walkthrough, step-by-step, of deploying a Django project to production with security in mind. At the end of the course I'll wrap up with showing you how you can automate updates and backups.
When you're done with the course you'll know all my tips and tricks, have a solid understanding of the architecture to make well informed choices.
You can ask me questions in the Q&A section of the course and learn from others. If you have a unique situation, share your question and I will help you. Remember, you're not just buying a set of videos, you're taking a course and I am a resource for you as your instructor.
Students should already have proficient Linux and Python skills with some familiarity with Django.