Version 15 (modified by 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
- 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.
- Change directory into
/local/
and create a virtual environment:
cd /local/ && virtualenv --no-site-packages venv
- Activate the virtual environment:
source /local/venv/bin/activate
- Download your application from a repository such as GitHub. Go to the application directory and install Flask and the other requirements by running the command:
pip install -r requirements.txt
Apache Setup
- Edit the Apache config:
vi /local/apache2/etc/httpd.conf
- 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}}}
- Edit the Apache modules conf:
vi /local/apache2/etc/loadmodule.conf
- Add the following line to the end of the file:
LoadModule wsgi_module /opt/python3/lib/mod_wsgi.so
- Restart Apache using the command:
sudo /etc/init.d/uol.apache2 restart
Note:
See TracWiki
for help on using the wiki.