wiki:UoL LAMP HowTo Install Python Flask Applications

Version 14 (modified by Richard Bramley, 6 years ago) ( diff )

--

UoL LAMP HowTo Install Python Flask Applications

Tags: HowTo Install Pain in the proverbial UoL LAMP Server

This page is for python 3, for python 2 see UoL LAMP HowTo Install Legacy Python Flask Applications

Create Environment

  1. Add python 3 to your path by adding the following line to .profile file in your home directory:
PATH=$PATH:/opt/python3/bin/

You will need to log off and log back in to add the above to your current environment.

  1. Change directory into /local/ and create a virtual environment:
cd /local/ && virtualenv --no-site-packages venv
  1. Activate the virtual environment:
source /local/venv/bin/activate
  1. Download the application repository from GitHub, cd into the application directory and install the requirements by running the command:
pip install -r requirements.txt

Apache Setup

  1. Edit the Apache config:
vi /local/apache2/etc/httpd.conf
  1. Amend the values below the comment # List of resources to look for when the client requests a directory to be:
# List of resources to look for when the client requests a directory
DirectoryIndex index.html

WSGIDaemonProcess application user=wwwrun threads=5 python-path=/local/venv/lib/python3.5/site-packages home={{{path to application folder}}}
WSGIScriptAlias / {{{path to application}}}

  1. Edit the Apache modules conf:
vi /local/apache2/etc/loadmodule.conf
  1. Add the following line to the end of the file:
LoadModule      wsgi_module             /opt/python3/lib/mod_wsgi.so
  1. Restart Apache using the command:
sudo /etc/init.d/uol.apache2 restart

Error: Macro BackLinks(None) failed
'Environment' object has no attribute 'get_db_cnx'

Note: See TracWiki for help on using the wiki.