How Do I Deploy a Django App on Your VPS or Shared Server? IntroductionDeploying a Django app does not have to be complicated. Whether you are using a shared hosting plan under Django Hosting or a VPS Hosting environment, you can set it up easily using CloudLinux Passenger, SSH terminal, or Gunicorn and Nginx on a VPS.In shared hosting, you will typically use cPanel Setup Python App, while on a VPS you will manually configure Gunicorn and Nginx for full control.This guide explains both methods step by step, so you can deploy your Django project smoothly and confidently, even if this is your first time working with a Python application. PrerequisitesBefore you begin, make sure you have:A Django project ready to deployPython 3.6+ (check supported versions in your hosting account)Access to cPanel or SSH terminalYour requirements.txt fileA configured database (SQLite, MySQL, or PostgreSQL)Basic familiarity with Django’s structure (settings.py, manage.py, etc.)Note: Always test your app locally before deployment. Run python manage.py runserver on your system to confirm everything works fine. Deployment on Shared Hosting (Using Passenger) Shared hosting is ideal if you want a simpler setup without server-level configurations.Here’s how you can deploy Django using cPanel’s Python App Setup tool (powered by CloudLinux Passenger). Step 1: Log in to the cPanel AccountGo to your hosting control panel and open cPanel.Look for Setup Python App under the Software section. Step 2: Create a New Python AppClick “Create Application”Choose your Python version (for example, 3.9 or 3.10)Set your application root (e.g., /home/user/my_django_app)Define the application URL (e.g., https://example.com)Choose your startup file — for Django, this is typically passenger_wsgi.pyOnce done, click Create. Passenger automatically creates a virtual environment and manages your app’s process, so you don’t need to configure WSGI manually. Step 3: Upload Your Django ProjectUse File Manager or FTP/SFTP to upload your Django project files to the directory you set as your application root.For example: /home/username/my_django_app/ Make sure your app.py file and Django project folder (e.g., /myproject/) are inside this directory. Step 4: Access Terminal (SSH)Terminal access is available under Advanced → Terminal in cPanel.Use it to activate your virtual environment and install dependencies: # source /home/username/virtualenv/my_django_app/3.9/bin/activate # pip install -r requirements.txt Note: If your hosting plan doesn’t include Terminal, ask support to enable SSH access temporarily. Step 5: Set Up passenger_wsgi.pyIn your app’s root folder, make sure you have a file named passenger_wsgi.py containing: import sys, os sys.path.insert(0, os.path.dirname(__file__)) os.environ[‘DJANGO_SETTINGS_MODULE’] = ‘myproject.settings’ from django.core.wsgi import get_wsgi_application a pplication=get_wsgi_application() Replace myproject.settings with your actual project settings path. Step 6: Apply Migrations and Collect Static FilesRun the following commands inside the terminal (after activating your virtual environment): # python manage.py migrate # python manage.py collectstatic This ensures your database and static assets are properly configured. Step 7: Restart the AppGo back to cPanel → Setup Python App → click Restart.Your Django application should now load on your domain.You’ve successfully deployed Django on shared hosting! Deployment on VPS (Using Gunicorn and Nginx)If you’re using a VPS, you’ll have full root access, which means you can configure Django more efficiently using Gunicorn as the application server and Nginx as a reverse proxy. Step 6: Apply Migrations and Collect Static FilesStep 1: Update PackagesStep 2: Install Required PackagesStep 3: Clone or Upload Your Django ProjectStep 4: Create Virtual Environment Step 5: Run Migrations # sudo apt update && sudo apt upgrade -y # sudo apt install python3 python3-pip python3-venv nginx -y # cd /var/www/ # sudo mkdir myproject && cd myproject # sudo git clone https://github.com/yourusername/yourproject.git. # python3 -m venv venv # source venv/bin/activate # pip install -r requirements.txt # python manage.py migrate # python manage.py collectstatic Step 6: Configure GunicornCreate a Gunicorn service file: # sudo nano /etc/systemd/system/gunicorn.service Add the following: [Unit] Description=gunicorn daemon for Django After=network.target [Service] User=root Group=www-data WorkingDirectory=/var/www/myproject ExecStart=/var/www/myproject/venv/bin/gunicorn –workers 3 –bind unix:/var/www/myproject/myproject.sock myproject.wsgi:application [Install] WantedBy=multi-user.target Save and run: # sudo systemctl daemon-reload # sudo systemctl enable gunicorn # sudo systemctl start gunicorn Step 7: Configure NginxEdit Nginx configuration: # sudo nano /etc/nginx/sites-available/myproject Add: server { listen 80; server_name yourdomain.com; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /var/www/myproject; } location / { include proxy_params; proxy_pass http://unix:/var/www/myproject/myproject.sock; } } Then enable it: # sudo ln -s /etc/nginx/sites-available/myproject /etc/nginx/sites-enabled # sudo systemctl restart nginx Your Django app should now be running on your VPS. Setting Up a Virtual EnvironmentBoth shared and VPS setups use virtual environments to isolate dependencies.This avoids conflicts with global Python packages and allows your app to run safely.Use: # python3 -m venv venv # source venv/bin/activate # pip install -r requirements.txt Always activate your virtual environment before running Django commands. Configuring DatabasesYou can use SQLite, MySQL, or PostgreSQL depending on your plan.In settings.py, configure your preferred backend:For MySQL: DATABASES = { ‘default’: { ‘ENGINE’: ‘django.db.backends.mysql’, ‘NAME’: ‘dbname’, ‘USER’: ‘dbuser’, ‘PASSWORD’: ‘dbpass’, ‘HOST’: ‘localhost’, ‘PORT’: ‘3306’, } } For SQLite (default): DATABASES = { ‘default’: { ‘ENGINE’: ‘django.db.backends.sqlite3’, ‘NAME’: BASE_DIR / “db.sqlite3”, } } Collecting Static and Media FilesDjango requires you to collect static files before serving them: # python manage.py collectstatic Then, define where your files should live in settings.py: STATIC_URL = ‘/static/’ STATIC_ROOT = BASE_DIR / ‘static’ MEDIA_URL = ‘/media/’ MEDIA_ROOT = BASE_DIR / ‘media’ Common Deployment MistakesForgetting to run collectstaticNot setting DEBUG=False in productionMissing ALLOWED_HOSTS entries in settingsNot activating the virtual environmentUsing the wrong Python versionNot restarting Passenger or Gunicorn after updates Troubleshooting TipsIf the app shows 500 Internal Server Error, check the logs:# tail -n 50 passenger.logIf static files don’t load, confirm paths in settings.pyRestart your app from cPanel or systemctl restart gunicorn on VPS ConclusionDeploying Django on shared or VPS hosting is simple when you follow the right steps.For shared hosting, Passenger handles most of the setup for you, while on VPS, Gunicorn + Nginx gives you full power and flexibility.With virtual environments, terminal access, and proper static file management, your Django app can run smoothly and securely. Need Help? If you require assistance at any point while using this guide, our Support Team is here to help: Email: support@bigcloudy.com Submit a support ticket FAQ Can I deploy Django using Git?Yes, both cPanel and VPS allow Git integration. You can pull directly from GitHub to your app directory. How long does deployment take?Usually less than 10 minutes once your files and dependencies are ready. Can I switch from shared to VPS later?Yes, you can migrate your Django app easily using the same structure. What if I get a 503 error?It usually means Passenger or Gunicorn isn’t running. Restart your app or check your startup file. Can I access the Django admin panel?Yes, once the site is live, just go to /admin and log in with your credentials.