Applicable to:
- Plesk for Linux
Question
- How to host Python applications in Plesk?
- How to deploy Django applications in Plesk?
- How to deploy Flask applications in Plesk?
Answer
As of Plesk Obsidian 18.0.79, Plesk supports WSGI-based apps (including Django, Flask, etc.) via the Python extension.
A couple of sample apps are available on the official Plesk GitHub account:
Prerequisites
- Log in to Plesk.
- Install the Python extension.
- Make sure the subscription's service plan has the "Python support management" permission:
- Navigate to Service Plans > Example > Permissions tab.
- Mark Python support management.
- Click OK.
Deploy the Flask demo app directly through the extension
- Navigate to Domains > example.com > Get Started tab.
- Click Install Demo App.
- Open the Application URL.
Note: The Install Demo App button is available only if Python is not enabled on the domain and no applications are installed or detected.
Deploy the Django demo app manually
- Navigate to Domains > example.com > Get Started tab > Enable Python.
- Navigate to Domains > example.com > Files.
-
In the Home Directory, upload the app's ZIP file and extract it.
Note: In this example, the app's ZIP file was downloaded from Plesk's demo Django project.
- Navigate to Domains > example.com > Python.
- Click Scan. The extension searches the webspace for a Python application and sets the Application root and the Document root accordingly.
- Make sure the Application root is /django-demo-main and the Document root is /django-demo-main/static. If not, set them manually:
- Click the Application root link and select django-demo-main.
- Click the Document root link and select django-demo-main/static.
- Click Create Virtual Environment.
- Click Install Dependencies.
- Click Restart App.
- Open the Application URL.
Warning: The Django demo app is for testing only. It runs with DEBUG enabled, uses a hardcoded SECRET_KEY, and accepts requests for any host.
Additional information
To deploy your own existing app, it must be a WSGI app and contain the following in the Application root:
-
passenger_wsgi.py, exposing the WSGI callable asapplication:Django:
CONFIG_TEXT: from <project>.wsgi import application
Flask (app object named
appinmain.py):CONFIG_TEXT: from main import app as application
- One of the following dependency files:
-
pyproject.tomlwithuv.lock requirements.txt
-
Comments
Please sign in to leave a comment.