AWS nginx+python+flask

Run an instance in EC2 (The key-pair is set after the launch button is pressed)

Don’t forget to modify the security group to permit all tcp connections.

Install packages from this article

Do all the steps but a bit differently:

  • Don’t change /etc/nginx/nginx.conf
  • Create a file /etc/nginx/sites-available/test:
server {
listen 10081;
    location / {
include uwsgi_params;
uwsgi_pass unix://var/run/uwsgi.sock;
  • Create simlink:
sudo ln -s /etc/nginx/sites-available/test /etc/nginx/sites-enabled
  • Create a flask application file
from flask import Flask
app = Flask(__name__)
def hello_world():
return ‘Hello World!’
if __name__ == ‘__main__’:’', port=10081)
  • Create a uwsgi file uwsgi.yaml
socket: /run/uwsgi.sock
master: 1
workers: 1
pidfile: /tmp/
#daemonize: /var/log/uwsgi.log
module: test:app
uid: www-data
gid: www-data
chmod-socket: 664
chown-socket: www-data:www-data
  • Run sudo uwsgi — yaml uwsgi.yaml
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.