Instructions


  1. Install python wsgi apache module.

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

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

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

    1touch my_flask_app.wsgi
  5. Create Apache config file for flask application.

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

    1sudo a2ensite /etc/apache2/sites-available/ExampleFlask.conf
  7. Restart Apache2.

    1apache2 -f /etc/apache2/apache2.conf -k stop 2apache2 -f /etc/apache2/apache2.conf -k start

Related articles


Filter by label (Content by label)

Related issues


Page Properties

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