Git Product home page Git Product logo

apf's Introduction

APF

Apache Python Flask

Install Dependencies

  1. Install Apache

  2. Install Python

  3. Install wsgi (via pip) pip3 install mod_wsgi

  4. Install Flask (via pip)

  5. Create Virtual Environment python3 -m venv venv

  6. Active Environment: . venv/bin/activate (to deactivate, type deactivate

Configure Local Apache

Your local apache config will differ based on os. For mac it's httpd.conf and for linux it's apache2.conf

  1. Go into your apache config (httpd.conf) and update the values as described here

This step may not be necessary, but it's the first thing I did. Mainly you want to update your User and Group to be your computer's active User and Group (the user displayed when you open a terminal. Type whoami to see what is what.

  1. Create an apache config file for your application. See docs

Copy and paste this to /etc/apache2/other/MyApp.conf Make sure to change the paths (USING ONLY ABSOLUTE PATHS) and the user and group to match

Point the WSGI alias to your app.wsgi file in your project

<VirtualHost *>
     # Add machine's IP address (use ifconfig command)
     ServerName localhost
     # Give an alias to to start your website url with
     WSGIDaemonProcess /Users/rchacon/code/github/orpheus/python/APF user=rchacon group=staff threads=5
     WSGIScriptAlias / /Users/rchacon/code/github/orpheus/python/APF/app.wsgi
     <Directory /Users/rchacon/code/github/orpheus/python/APF>
     		# set permissions as per apache2.conf file
        # WSGIProcessGroup APF
        # WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        # AllowOverride All
        Allow from all
     </Directory>
     ErrorLog /tmp/error.log
     LogLevel warn
     CustomLog /tmp/access.log combined
</VirtualHost>
  1. Add wsgi module to your apache config httpd.conf. Run this command to and add it's output to your httpd.conf: mod_wsgi-express module-config If that command doesn't exist, you need to find out where the wsgi module lives in your computer and add: LoadModule wsgi_module /path/to/module.so

  2. in your httpd.conf, change Require all none to Require all granted at your root <Directory /> ... </Directory> tag (do a search for <Directory /> and find the one without any arguments passed to it.

<Directory />
    AllowOverride none
    Require all granted
</Directory>
  1. add Include /etc/apache2/other/*.conf to your httpd.conf. Change the path to wherever your custom application configurations go

  2. Restart your apache server

  3. Your app should be running on localhost

Simply Apache Summary

  1. Make sure python, flask, apache, and wsgi are installed
  2. Create an Apache config for your application
  3. Create a .wsgi file for your python app
  4. Load the wsgi module in the Apache config
  5. Restart your apache server for changes to take effect

Start App Locally With Flask

export FLASK_ENV=development

flask run

Mac Apache Commands

Start: sudo apachectl start

Stop: sudo apachectl stop

Config: vi /etc/apache2/httpd.conf

Restart: sudo apachectl -k restart

apf's People

Contributors

orpheus avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.