How to Install Django on VPS and Dedicated Server
How to Install Django on a Hosting Server: A Step-by-Step Guide
Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Whether you’re launching a small website or a full-fledged web application, deploying Django on a hosting server is a critical step. In this guide, we’ll walk through the process of installing Django on a typical Linux-based hosting server.
✅ Prerequisites
Before beginning, make sure your hosting server has the following:
Access via SSH
Python 3.6+ installed
pip (Python package manager)
Virtualenv (optional but recommended)
A domain or subdomain (optional)
Basic knowledge of Linux commands
Step 1: Connect to Your Server via SSH
ssh username@your_server_ipReplace
usernameand
your_server_ipwith your actual server credentials.
Step 2: Create a Project Directory
Navigate to the directory where you want your Django project to live:
mkdir ~/myproject
cd ~/myprojectStep 3: Set Up a Virtual Environment
Using
virtualenvis a good practice to isolate your project’s dependencies.
python3 -m venv venv
source venv/bin/activateOnce activated, your terminal prompt will reflect the virtual environment.
Step 4: Install Django
With the virtual environment active, run:
pip install djangoYou can check the installation with:
django-admin --versionStep 5: Create a Django Project
Now you can create a new Django project:
django-admin startproject mysite .The dot at the end ensures the files are placed in the current directory.
Step 6: Run Migrations and Create Superuser
Run initial database migrations:
python manage.py migrateCreate an admin user:
python manage.py createsuperuserFollow the prompts to set up a username and password.
Step 7: Test Django with Built-in Server
For initial testing, use Django’s built-in server:
python manage.py runserver 0.0.0.0:8000You can now visit your server’s IP address on port 8000 in the browser:
http://your_server_ip:8000Step 8: Prepare for Production
For production use, you’ll need:
Gunicorn or uWSGI as a WSGI server
Nginx or Apache as a reverse proxy
PostgreSQL or MySQL if not using SQLite
SSL certificate (optional but highly recommended)
Install Gunicorn:
pip install gunicornRun Gunicorn:
gunicorn --bind 0.0.0.0:8000 mysite.wsgiFor a production setup, configure a systemd service and a reverse proxy with Nginx to manage traffic and ensure your app runs continuously.


