Articles in this section

How to configure root directory for WSGI scripts with Plesk?

kb: how-to Plesk for Linux ABT: Group B

Applicable to:

  • Plesk for Linux

Question

How to run Python scripts using WSGI module?

How to configure domain root directory for WSGI scripts?

Answer

Warning: WSGI module is not compatible with the Python module and Apache will crash if installed together.

  1. Connect to the server via SSH

  2. Install mod_wsgi Apache module:

    For Red Hat based OS:

    # yum install mod_wsgi

    For Debian based OS:

    # apt-get install libapache2-mod-wsgi

    Note: for some versions of Ubuntu the package name is libapache2-mod-wsgi-py3

    For AlmaLinux:

    # yum install python3-mod_wsgi

  3. Restart Apache service:

    For Red Hat based OS:

    # systemctl restart httpd

    For Debian based OS:

    # systemctl restart apache2

  4. Log in to Plesk

  5. Under Domains > example.com > Apache & nginx Settings > Additional directives for HTTP specify the following:

    Note: Duplicate it to the field Additional directives for HTTPS if necessary:

    WSGIScriptAlias /python /var/www/vhosts/example.com/httpdocs/python/

  6. After that, the file *.py will be served on the URL _**http://example.com/python/<file_name>**_ .

Note: path /var/www/vhosts/example.com/httpdocs/python may vary, depending on where the script is located.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.