Your Cart

Get Amazing Offers on Scripts

Get UX Support

How to setup Django application on Cloudpanel with uWSGI and nginx

In this blog, I am going to show you how to simply setup Django application on Cloudpanel 2 with uWSGI and nginx

This tutorial is aimed at the Django user who wants to set up a production web server. It takes you through the steps required to set up Django so that it works nicely with uWSGI and nginx. It covers all three components, providing a complete stack of web application and server software.

CloudPanel is a free software to configure and manage a server with an obsessive focus on simplicity.
Run static websites, PHP, Node.js and, Python applications.

Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.

nginx (pronounced engine-x) is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server.

A Web Server Gateway Interface – WSGI – does this job. WSGI is a Python standard.

uWSGI is a WSGI implementation. In this tutorial we will set up uWSGI so that it creates a Unix socket, and serves responses to the web server via the uwsgi protocol. At the end, our complete stack of components will look like this:

					the web client <-> the web server <-> the socket <-> uwsgi <-> Django
  1. First go to your Cloudpanel Hosting, then go to Add site

2. Create a Python site

3. Add and note details given below:

1) Domain name –

2) App port – 8090

3) Site User – tutorialslides

Now click on Create

4. Now install SSL Let’s Encrypt Certificate

5. Log in via SSH with the Root User and go to the uwsgi apps directory: Use Filezilla

					cd /etc/uwsgi/apps-enabled/

6 . Create a configuration file like Domain Name given above  domain.uwsgi.ini and modify the example configuration below to your needs:

plugins       = python3
master        = true
protocol      = uwsgi
socket        = /home/tutorialslides/htdocs/

# Note: Below code wsgi-file  is very important as In your django project find and give path properly. 
#In my project wsgi-file is inside Food folder
wsgi-file     = /home/tutorialslides/htdocs/

chdir         = /home/tutorialslides/htdocs/

module        = Food/

home = /home/tutorialslides/htdocs/
master = true

# Needed for OAuth/OpenID
buffer-size   = 8192

# Reload when consuming too much of memory
reload-on-rss = 250

# Increase number of workers for heavily loaded sites
workers       = 4

# Enable threads for Sentry error submission
enable-threads = true

# Child processes do not need file descriptors
close-on-exec = true

# Avoid default 0000 umask
umask = 0022

# Enable harakiri mode (kill requests after some time)
# harakiri = 3600
# harakiri-verbose = true

# Enable uWSGI stats server
# stats = :1717
# stats-http = true

# Do not log some errors caused by client disconnects
ignore-sigpipe = true
ignore-write-errors = true
disable-write-exception = true

Note: Below code wsgi-file is very important as In your django project find and give path properly. In my project wsgi-file is inside Food folder.

7. Make sure after upload your extension should be correct

Note: In windows , Extension may not create properly so make sure after uploading uwsgi.ini file verify it. If extension  is missing as given below . Rename file name

8. Now Activate venv and install all the project files and django as well. Path given below

					# Go to your folder first
cd /home/tutorialslides/htdocs/

# Create Venv
python -m venv env
# or 
python3 -m venv env

# Activate Venv
source env/bin/activate

# Install django and copy all the files to the project folder

python -m pip install Django


9. Now change Vhost Default values

					upstream django {
   server unix:/home/tutorialslides/htdocs/;
    #server; # for a web port socket (we'll use this first)

server {
  listen 80;
  listen [::]:80;
  listen 443 ssl http2;
  listen [::]:443 ssl http2;

client_max_body_size 75M;   # adjust to taste

    # Django media
    location /media  {
        alias /home/tutorialslides/htdocs/;  # your Django project's media files - amend as required

    location /static {
        alias /home/tutorialslides/htdocs/; # your Django project's static files - amend as required

charset     utf-8;

  if ($scheme != "https") {
    rewrite ^ https://$host$uri permanent;


  location ~ /.well-known {
    auth_basic off;
    allow all;


  index index.html;

  location / {
    uwsgi_read_timeout 3600;
    #uwsgi_pass  unix:/home/tutorialslides/htdocs/;
      uwsgi_pass  django;
       include uwsgi_params;

  #location ~* ^.+\.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|woff2|eot|mp4|ogg|ogv|webm|webp|zip|swf)$ {
  #  add_header Access-Control-Allow-Origin "*";
  #  expires max;
  #  access_log on;

  if (-f $request_filename) {

10. Now restart ngnix and wsgi

					sudo /etc/init.d/nginx restart

sudo systemctl reload nginx
sudo systemctl restart uwsgi

11. Now try to run code. if your website is running properly or not

					#change Food/ with your path
uwsgi --socket tutorialslides.sock --wsgi-file Food/

12. If working properly, Reboot server


That’s it. If you are facing any issues. Please do reach out to me for paid support.

Still facing Issues ?

Contact me for paid support​ Mail me @
Paid Support
Leave a Reply
Free Worldwide shipping

On all orders above $50

Easy 30 days returns

30 days money back guarantee

International Warranty

Offered in the country of usage

100% Secure Checkout

PayPal / MasterCard / Visa