Magesh Ravi
Artist | Techie | Entrepreneur
Earlier this week, I published my first e-book titled "Deploy your Django app on any VPS: A Practical Guide to Nginx, uWSGI, and Systemd Setup"
This ebook guides you through the process of setting up a basic Django application with an SQLite database on a Debian/Ubuntu server. The steps provided can be used to deploy the Django project available at https://github.com/Webinative/sample-django to a VPS running Ubuntu 22.04 LTS. These steps should also be applicable to other cloud providers such as DigitalOcean, AWS (Lightsail or EC2), and GCP.
You can grab your copy here – https://mageshravi.gumroad.com/l/deploy-django-nginx-uwsgi.
If you come across any questions, errors, or need help with deploying your application, feel free to contact me on Discord or on Telegram.
I'm providing the first chapter here for free to help you evaluate your purchase.
Before we dive into deployment, let's grasp the key components and the folder structure.
For our setup, we require: 1. Web Server: To serve static files like CSS, JS, and images. 2. Application Container: To run our Django app.
We'll opt for Nginx as the web server and uWSGI as the application container.
Assuming our application is deployed to the mywebsite.com
domain, the necessary folder structure looks like this:
/var/www/
├── mywebsite.com
└── media.mywebsite.com
/home/webinative/
├── backups/mywebsite.com
├── logs/mywebsite.com
├── releases/mywebsite.com
├── venv/mywebsite.com
└── www/mywebsite.com
Here's what each folder serves:
/var/www/mywebsite.com
: Web root for Nginx, where static files reside./var/www/media.mywebsite.com
: Holds user-uploaded files (media root)./home/webinative/logs/mywebsite.com
: Contains application-related logs./home/webinative/releases/mywebsite.com
: Stores software release TAR balls./home/webinative/venv/mywebsite.com
: The virtual environment folder./home/webinative/www/mywebsite.com
: The Django project folder.To ensure security, we'll create a new user, webinative
, with restricted permissions to run the Django application. Running the application as the root
user is avoided for obvious security reasons.
I hope the first chapter provides a bird's eye-view of the process and the setup. You can buy the complete eBook here – https://mageshravi.gumroad.com/l/deploy-django-nginx-uwsgi.