Plesk can host Python web applications such as Flask and Django using Phusion Passenger as the application server. Setup requires some server-side configuration, but once done your app runs directly from the Plesk interface.

Prerequisites

  • Phusion Passenger and Python must be installed on the server. If the Python option is not available, contact your hosting provider.
  • Your application files ready with a requirements.txt listing all dependencies.
  • SSH access may be required for installing Python packages.

Step 1: Upload your application

  1. Log in to Plesk.
  2. Go to Websites & Domains and find your domain.
  3. Upload your Python app files to the domain directory using File Manager, FTP, or the Git extension.
  4. Make sure requirements.txt is in the application root directory.

Step 2: Configure the Python application

  1. Go to Websites & Domains and click the Python icon on your domain card.
  2. Click Enable Python.
  3. Set the Python Version to match the version your app was built with.
  4. Set the Application Root to the directory containing your app files (e.g. /httpdocs).
  5. Set the Application Startup File:
    • For Flask: app.py (or whatever file contains your Flask app)
    • For Django: passenger_wsgi.py (see Step 3)
  6. Set Application Mode to Production when your app is ready to go live.

Step 3: Create passenger_wsgi.py (Django only)

Django applications need a bridge file for Phusion Passenger. Create a file called passenger_wsgi.py in your application root with the following content:

import sys, os
sys.path.append(os.getcwd())
from myproject.wsgi import application

Replace myproject with your actual Django project folder name.

Step 4: Install dependencies

  1. In the Python application settings, click Run Pip Install. Plesk creates a virtual environment and installs everything from requirements.txt.
  2. Alternatively, SSH into your server and run:
    cd /var/www/vhosts/yourdomain.com/httpdocs && pip install -r requirements.txt

Step 5: Run database migrations (Django)

In the Python settings, use Run Script with:

  • Script name: manage.py
  • Arguments: migrate

Repeat with collectstatic to gather static files.

Step 6: Restart and verify

  1. Click Restart Application in the Python settings.
  2. Visit your domain in a browser to verify the app is running.

Troubleshooting

  • Phusion Passenger error page: Check the Logs tab on your domain card for Python traceback errors.
  • Module not found errors: Run Pip Install again or verify your requirements.txt is complete.
  • Static files not loading (Django): Make sure you ran collectstatic and your STATIC_ROOT is configured in settings.
  • App not restarting: Create a tmp directory in your app root and run touch tmp/restart.txt via SSH to force a restart.
Was this answer helpful? 0 Users Found This Useful (0 Votes)