Deploying a Django app on a VPS gives you full control over your project’s performance, scalability, and security. In this complete 2025 guide, you’ll learn how to deploy your Django app using Gunicorn as the application server and Nginx as the reverse proxy (How to Deploy a Django app on VPS Nginx Gunicorn) — a powerful and production-ready setup.
✅ What You’ll Need:
- A VPS running Ubuntu 22.04 or 24.04
- Root or sudo user access
- SSH access to your VPS
- A Django app ready for deployment
- A domain name (optional, but recommended)
🔧 Step 1: Connect to Your VPS
Open your terminal and connect via SSH:
ssh youruser@your-vps-ip
🔄 Step 2: Update Your System
sudo apt update && sudo apt upgrade -y
📦 Step 3: Install Required Packages
sudo apt install python3-pip python3-dev libpq-dev nginx curl -y
🐍 Step 4: Set Up a Virtual Environment
sudo apt install python3-venv -y
cd ~
mkdir myproject && cd myproject
python3 -m venv venv
source venv/bin/activate
🧱 Step 5: Install Django and Gunicorn
pip install django gunicorn
If you have an existing Django project, clone it here or copy it into the
myprojectfolder.
⚙️ Step 6: Configure Django for Production
In settings.py:
- Set
DEBUG = False - Add your server IP or domain to
ALLOWED_HOSTS:
ALLOWED_HOSTS = ['yourdomain.com', 'your.vps.ip']
Collect static files:
python manage.py collectstatic
🔥 Step 7: Test Gunicorn
Run this command in your Django project root:
gunicorn --workers 3 myproject.wsgi:application
If it works, press CTRL+C and let’s set up a systemd service.
🧩 Step 8: Create a Gunicorn systemd Service
sudo nano /etc/systemd/system/gunicorn.service
Paste this (replace values as needed):
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=youruser
Group=www-data
WorkingDirectory=/home/youruser/myproject
ExecStart=/home/youruser/myproject/venv/bin/gunicorn --workers 3 --bind unix:/home/youruser/myproject/myproject.sock myproject.wsgi:application
[Install]
WantedBy=multi-user.target
Then:
sudo systemctl start gunicorn
sudo systemctl enable gunicorn
🌐 Step 9: Set Up Nginx
Create a config file:
sudo nano /etc/nginx/sites-available/myproject
Paste this:
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/youruser/myproject;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/youruser/myproject/myproject.sock;
}
}
Enable the site and test:
sudo ln -s /etc/nginx/sites-available/myproject /etc/nginx/sites-enabled
sudo nginx -t
sudo systemctl restart nginx
🔒 Step 10: Secure Your Domain with HTTPS (Optional but Recommended)
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx
Follow the prompts to install a free SSL certificate.
🎉 Final Step: Visit Your App!
Go to http://yourdomain.com (or https:// if you enabled SSL). Your Django app is now live!
🏁 Conclusion
You’ve just learned how to deploy a Django app on a VPS using Nginx and Gunicorn — one of the most powerful, scalable setups for 2025. This approach ensures speed, security, and professional-grade performance.
✅ Quick Recap:
- ✅ Gunicorn handles Django processes
- ✅ Nginx acts as a reverse proxy
- ✅ HTTPS with Certbot improves security
- ✅ This setup is scalable and production-ready


