Articles in this section

How to host Python applications in Plesk?

kb: how-to Plesk for Linux

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

  1. Log in to Plesk.
  2. Install the Python extension.
  3. Make sure the subscription's service plan has the "Python support management" permission:
    1. Navigate to Service Plans > Example > Permissions tab.
    2. Mark Python support management.
    3. Click OK.

Deploy the Flask demo app directly through the extension

  1. Navigate to Domains > example.com > Get Started tab.
  2. Click Install Demo App.
  3. 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

  1. Navigate to Domains > example.com > Get Started tab > Enable Python.
  2. Navigate to Domains > example.com > Files.
  3. 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.

  4. Navigate to Domains > example.com > Python.
  5. Click Scan. The extension searches the webspace for a Python application and sets the Application root and the Document root accordingly.
  6. Make sure the Application root is /django-demo-main and the Document root is /django-demo-main/static. If not, set them manually:
    1. Click the Application root link and select django-demo-main.
    2. Click the Document root link and select django-demo-main/static.
  7. Click Create Virtual Environment.
  8. Click Install Dependencies.
  9. Click Restart App.
  10. 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 as application:

    Django:

    CONFIG_TEXT: from <project>.wsgi import application

    Flask (app object named app in main.py):

    CONFIG_TEXT: from main import app as application

  • One of the following dependency files:
    • pyproject.toml with uv.lock
    • requirements.txt
Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.