Flask Config – Ubuntu 16

  • Create a user for the project if one doesn’t exist
  • Add the user to sudoers if desired
  • Install the requisite packages
  • SSH in as the user
  • Create a project directory
  • Initialize a virtual environment
  • Activate the virtual environment
  • Install Flask and uWSGI
  • Create a test page at  /home/user/projectdir/test_page.py , example:
  • Create the WSGI entry point at  /home/user/projectdir/wsgi.py , example:
  • Create uWSGI config file at /home/user/projectdir/test_page.ini , example:
  • Create a systemd Unit file to create a service at  /etc/systemd/system/test_page.service , example:
  • Start up the service
  • Create nginx vhost at  /etc/nginx/sites-available/myproject , example:
  • Enable the vhost by symlinking to  /etc/nginx/sites-enabled/
  • Test the config and restart nginx if all is well
  • Create a firewall rule allowing traffic to/from nginx
  • The site will load at the  server_name set in the nginx vhost, make sure DNS is pointed, or use an IP.