= 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. 2. Change directory into `/local/` and create a virtual environment: {{{ cd /local/ && virtualenv --no-site-packages venv }}} 3. Activate the virtual environment: {{{ source /local/venv/bin/activate }}} 4. Download the application repository from [https://github.com/LCBRU 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 }}} 2. 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}}} }}} 3. Edit the Apache modules conf: {{{ vi /local/apache2/etc/loadmodule.conf }}} 4. Add the following line to the end of the file: {{{ LoadModule wsgi_module /opt/python3/lib/mod_wsgi.so }}} 5. Restart Apache using the command: {{{ sudo /etc/init.d/uol.apache2 restart }}} [[BackLinks]]