Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Instructions

  1. Install python wsgi apache module.

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

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

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

    Code Block
    languagebash
    touch my_flask_app.wsgi
  5. Create Apache config file for flask application.

    Code Block
    <VirtualHost *:80>
         # Add machine's IP address (use ifconfig command)
         ServerName 192.168.1.103
         # Give an alias to to start your website url with
         WSGIScriptAlias /testFlask /home/username/ExampleFlask/my_flask_app.wsgi
         <Directory /home/username/ExampleFlask/ExampleFlask/>
         		# set permissions as per apache2.conf file
                Options FollowSymLinks
                AllowOverride None
                Require all granted
         </Directory>
         ErrorLog ${APACHE_LOG_DIR}/error.log
         LogLevel warn
         CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
  6. Enable site from file with a2ensite.

    Code Block
    languagebash
    sudo a2ensite /etc/apache2/sites-available/ExampleFlask.conf
  7. Restart Apache2.

    Code Block
    languagebash
    apache2 -f /etc/apache2/apache2.conf -k stop
    apache2 -f /etc/apache2/apache2.conf -k start
Info

Filter by label (Content by label)
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@281cd3
showSpacefalse
sortmodified
typepage
reversetrue
labelskb-how-to-article
cqllabel = "kb-how-to-article" and type = "page" and space = "VCL2"
Page Properties
hiddentrue

Related issues

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