![]() |
|
Guide How to Deploy a Python App (Django or Flask) on CloudPanel with uWSGI - Printable Version +- AdminsForum (https://adminsforum.com) +-- Forum: Free & open-source control panels (https://adminsforum.com/Forum-free-open-source-control-panels) +--- Forum: CloudPanel (https://adminsforum.com/Forum-cloudpanel) +---- Forum: CloudPanel Guides & Tutorials (https://adminsforum.com/Forum-cloudpanel-guides-tutorials) +----- Forum: CloudPanel Node.js & Python Guides (https://adminsforum.com/Forum-cloudpanel-node-js-python-guides) +----- Thread: Guide How to Deploy a Python App (Django or Flask) on CloudPanel with uWSGI (/Thread-guide-how-to-deploy-a-python-app-django-or-flask-on-cloudpanel-with-uwsgi) |
How to Deploy a Python App (Django or Flask) on CloudPanel with uWSGI - JAY - 10-19-2026 How to deploy a Python app (Django or Flask) on CloudPanel with uWSGI CloudPanel has a Python site type for Django, Flask, FastAPI and other Python web apps. It creates the domain, a site user and an Nginx vhost that forwards requests to an App Port. For production, CloudPanel's own documentation runs the app with uWSGI, which is already installed with CloudPanel. This guide follows that setup. Step 1: Create the Python site
Step 2: Upload the app and create a virtual environment Log in over SSH as the site user and put your project in the site folder: Code: ssh site-user@YOUR_SERVER_IP
cd ~/htdocs
rm -rf www.example.com
git clone https://github.com/your-name/your-app.git www.example.com
cd www.example.com
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
deactivateCode: ALLOWED_HOSTSCode: DEBUG = FalseCode: python manage.py migrateCode: python manage.py collectstaticFind your app's WSGI entry point. For Django it's Code: yourproject/wsgi.pyCode: wsgi.pyCode: from app import app as applicationStep 3: Create the uWSGI config (as root) Log in as root and create a config file for the site: Code: cd /etc/uwsgi/apps-enabled/
nano www.example.com.uwsgi.iniCode: [uwsgi]
plugins = python3
master = true
protocol = uwsgi
socket = 127.0.0.1:8090
wsgi-file = /home/site-user/htdocs/www.example.com/yourproject/wsgi.py
virtualenv = /home/site-user/htdocs/www.example.com/venv
chdir = /home/site-user/htdocs/www.example.com
buffer-size = 8192
reload-on-rss = 250
workers = 4
enable-threads = true
close-on-exec = true
umask = 0022
uid = site-user
gid = site-user
ignore-sigpipe = true
ignore-write-errors = true
disable-write-exception = trueStep 4: Point the Nginx vhost to uWSGI In CloudPanel, open the site and go to the Vhost tab. The default vhost uses Code: proxy_passCode: location /Code: location / {
include uwsgi_params;
uwsgi_read_timeout 3600;
uwsgi_pass 127.0.0.1:{{app_port}};
}Code: {{app_port}}To let Nginx serve Django's static files directly, add a block like this above it (adjust the path to your STATIC_ROOT): Code: location /static/ {
alias /home/site-user/htdocs/www.example.com/static/;
}Step 5: Restart uWSGI and test Code: systemctl restart uwsgi
ss -tulpn | grep uwsgiCode: 127.0.0.1:8090After code changes, restart uWSGI again with Code: systemctl restart uwsgiStep 6: Add free SSL Go to SSL/TLS > Actions > New Let's Encrypt Certificate for the site. Guide: How to install free SSL in CloudPanel. Troubleshooting
Sources (checked October 2026): CloudPanel: Python deployment with uWSGI Not sure which site type to choose? See What can you host on CloudPanel? |