skip to primary navigationskip to content

Python 2.7 (Debian 8)

Python support in Debian 8 (Jessie)

Python v2.7 is installed on MWS servers running Debian 8 (Jessie) and the Apache module WSGI is installed by default.

This allows you to host a python website using a Python-based framework such as Django, Flask, etc. Please note that these frameworks are not provided on the MWS, so you would need to install them yourself in a virtual environment. Users are expected to be familiar with creating virtual environments and configuring a web application to work with Apache 2.4's mod_wsgi. We suggest using the admindir directory to store them.

In servers running Debian 8 (Jessie) use virtualenv to create your virtual environment.

You will need to configure your .htaccess properly in order to make your python-based website work.

Using Django on the MWS

  • Copy your Django project inside the docroot directory within your website space in your MWS site. This is usually /var/www/[site name]/docroot,  where [site name] will be the name of the website you have set up in the MWS web control panel.
  • Create a .htaccess file in /var/www/[site name]/docroot/ and add the following:
AddHandler wsgi-script .py
Options FollowSymlinks ExecCGI MultiViews Indexes
MultiviewsMatch Handlers
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ django_project/django_app/$1 [QSA,PT,L]
  • add to django_project/django_app/ the following:
import sys

You can also add your own virtualenv to the django_project/django_app/ file using sys.path.append and adding your virtualenv packages directory: venvdir/lib/python2.7/site-packages

Be sure to give correct permissions to your virtualenv folder.