Skip to content

Instantly share code, notes, and snippets.

@leg0ffant
Forked from ichpuchtli/README.md
Last active February 8, 2018 09:25
Show Gist options
  • Save leg0ffant/1b0d7f9597a119f33d73 to your computer and use it in GitHub Desktop.
Save leg0ffant/1b0d7f9597a119f33d73 to your computer and use it in GitHub Desktop.
ArchLinux ARM nginx+uwsgi+flask

Dependencies

$ pacman -Syu python-pip nginx uwsgi-plugin-python uwsgi
$ pip install flask

Directory nginx creation

$ sudo mkdir -p /etc/nginx/sites-enabled

Directory uwsgi creation

$ sudo mkdir -p /etc/uswgi/apps-available

Directory Files server management creation

$ sudo mkdir -p /var/www
  1. Editing configuration files

  1. Editing /etc/nginx/nginx.conf & remove fonction server ()

  2. Editing & add /etc/nginx/sites-enabled/appNginx.conf

  3. Editing & add /etc/uwsgi/apps-available/appUwsgi.ini

  4. Symlink creation root uwsgi


$ cd /etc/uwsgi
$ sudo ln -s /etc/uwsgi/apps-available/appUwsgi.ini appUwsgi.ini
  1. Python app creation

$ sudo nano /var/www/hello.py
  1. Configuration systemd & start service

$ sudo systemctl enable nginx
$ sudo systemctl start nginx
$ sudo systemctl enable uwsgi@appUwsgi
$ sudo systemctl start uwsgi@appUwsgi

Web testing IP local working if "Hello !" is in the screen

server {
listen 80;
server_name <ip_local>;
charset utf-8;
client_max_body_size 75M;
root /var/www;
# python flask apps
location / {
try_files $uri @webpi;
}
location @webpi {
include uwsgi_params;
#uwsgi_pass unix:/tmp/uwsgi.sock;
uwsgi_pass 127.0.0.1:3031;
}
}
[uwsgi]
#socket files's location
socket = 127.0.0.1:3031
#import plugin
plugins = python
#Module python import
module = flask_app
#application's base file
wsgi-file = /var/www/hello.py
#variable for flask apps
callable = app
process = 3
#permissions for the socket file
#chmod-socket = 666
#! /usr/bin/python
# -*- coding:utf-8 -*-
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return "Hello !"
if __name__ == '__main__':
app.run(debug=True)
#user http;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
include /etc/nginx/sites-enabled/*;
}
@uliantsev-a
Copy link

uliantsev-a commented Feb 8, 2018

Hello!
Your file READMY is possible misspellings, under part "Directory uwsgi creation".
"/etc/usWgi/apps-available" -> /etc/uwSgi/apps-available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment