Plesk

How to install Django applications in Plesk?

Question

How to install Django applications in Plesk?

Answer

While it is not yet officially supported, it can be configured manually at your own risk & will.
Vote for adding Python support to the Plesk on our UserVoice.

Note: Here and forth Python 3.x will be used as a target Python version.

Prepare the server

Connect to the server via SSH and apply the steps according to the installed Linux distribution:

Ubuntu and Debian

  1. Install Python 3:

    # apt install python3 python-is-python3

  2. Download and install the Python package manager from the official website:

    # wget https://bootstrap.pypa.io/get-pip.py
    # python3 get-pip.py

  3. Install the virtualenv package for python to separate the application's environment:

    # python3 -m pip install virtualenv

  4. Install Phusion Passenger, which will be used to run the application:

    # plesk installer --select-release-current --install-component passenger

  5. Log into Plesk

  6. Enable passenger module in Tools & Settings > Apache Web Server (in case the application should be served by Apache)

  7. Create a new service plan in Service Plans to preconfigure the web-server

  8. Set the following configuration in Web Server tab:

    • To have application served by Apache:

      • Enable Proxy mode, if it is present

      • Set the following Additional Apache directives (for HTTP and HTTPS) to enable processing:

        PassengerEnabled On

    • To have application served by nginx:

      • Disable Proxy mode

      • Set the following Additional nginx directives, to enable processing:

        passenger_enabled on;
        passenger_app_type wsgi;
        passenger_startup_file passenger_wsgi.py;

  9. Set the following configuration in Hosting Parameters tab:

    • Enable SSH access to the server shell under the subscription's system user. Set shell to /bin/bash

      Warning: Providing users with shell access might be insecure and may allow them to exploit OS vulnerabilities. Make sure that the server has the latest updates installed.

  10. Save the Service Plan and use it on subscriptions that should have Python applications installed

CentOS 7 and RHEL 7

  1. Add EPEL repository and install Python 3.6:

    # yum install -y epel-release
    # yum install -y python36

  2. Download and install the Python package manager from the official website:

    # wget https://bootstrap.pypa.io/pip/3.6/get-pip.py
    # python3.6 get-pip.py

  3. Install the virtualenv package for python to separate the application's environment:

    # python3.6 -m pip install virtualenv

  4. Install Phusion Passenger, which will be used to run the application:

    # plesk installer --select-release-current --install-component passenger

  5. Log into Plesk

  6. Enable passenger module in Tools & Settings > Apache Web Server (in case application should be served by Apache)

  7. Create a new service plan in Service Plans to preconfigure the web-server

  8. Set the following configuration in Web Server tab:

    • To have application served by Apache:

      • Enable Proxy mode, if it is present

      • Set the following Additional Apache directives (for HTTP and HTTPS) to enable processing:

        PassengerEnabled On

    • To have application served by nginx:

      • Disable Proxy mode

      • Set the following Additional nginx directives, to enable processing:

        passenger_enabled on;
        passenger_app_type wsgi;
        passenger_startup_file passenger_wsgi.py;

  9. Set the following configuration in the Hosting Parameters tab:

    • Enable SSH access to the server shell under the subscription's system user. Set shell to /bin/bash

      Warning…