May First web servers come with the minimal packages needed to run a python web application: the python binary (python3
), pip3
(the python package installer) and python3-venv
for creating virtual environments.
All python libraries needed for your web application should be installed locally. First access your web site via secure shell. Then use one of the following methods to install your dependencies:
First, ensure you can launch your service manually while logged in via ssh.
Next, setup a scheduled job configured to run "forever".
Please ensure your application listens only via localhost. We do not assign port numbers, so please pick a random port number higher than 1024.
To ensure people can access your application, edit your "Web Configuration" via the members control panel. Click "Show advanced settings" and add the following to the settings field (assuming your application is listening on port 8932):
RequestHeader set X-Forwarded-Proto 'https' env=HTTPS
ProxyPass /static !
ProxyPass / http://localhost:8932/
Assuming you have a working django application already, follow the steps below to get it working via May First.
~/include
directory of your web site, e.g. ~/include/my-app
pyproject.toml
file in the root of your django project with the contents: [tool.poetry]
name = "my-app"
version = "0.1.0"
description = "My great app."
authors = []
[tool.poetry.dependencies]
python = "^3.9"
Django = "^3.2"
Jinja2 = "^2.11.3"
curl -sSL https://install.python-poetry.org | python3 -
$HOME/.local/bin
to your path to make it easier to run poetry, django, etc.grep '.local/bin' ~/.profile >/dev/null || echo "export PATH=\"$HOME/.local/bin:\$PATH\"" >> ~/.profile
poetry shell
poetry install
python manage.py runserver
. If it succeeds, hit ctrl-cancel
to cancel./home/sites/<your-site-nuber>/.local/bin/poetry run python manage.py runserver
/home/sites/<your-site-number>/include/my-app
<Directory "/home/sites/<your-site-number>/include/my-app/static-root">
Require all granted
</Directory>
Alias /static /home/sites/<your-site-number>/include/my-app/static-root
RequestHeader set X-Forwarded-Proto 'https' env=HTTPS
ProxyPass /static !
ProxyPass / http://localhost:8000/
Be sure to replace "" with your actual site number as displayed in the members control panel.