LAMP Stack (Python + Flask)

Instructions

  1. Install python wsgi apache module.

    sudo apt-get install libapache2-mod-wsgi-py3 python-dev
  2. Install flask.

    pip3.6 install flask
  3. Verify Apache is running.

    apache2 -f /etc/apache2/apache2.conf -k start
  4. Create wsgi file with same name as python applicaton.

  5. Create Apache config file for flask application.

  6. Enable site from file with a2ensite.

  7. Restart Apache2.

Reference:

  • https://flask.palletsprojects.com/en/1.1.x/deploying/mod_wsgi/

  • https://github.com/GrahamDumpleton/mod_wsgi

  • https://www.codementor.io/@abhishake/minimal-apache-configuration-for-deploying-a-flask-app-ubuntu-18-04-phu50a7ft

  • https://modwsgi.readthedocs.io/en/develop/user-guides/configuration-guidelines.html

  • https://stackoverflow.com/questions/22711087/flask-importerror-no-module-named-app

  • https://stackoverflow.com/questions/31252791/flask-importerror-no-module-named-flask

  • https://stackoverflow.com/questions/338768/python-error-importerror-no-module-named