title: Deploying Python flask application using nginx/gunicorn on Amazon Linux EC2 instance
body: <p>I am trying to deploy a python flask app on an Amazon Linux EC2 instance. I am unable to spin up the upstart script and get it running. </p>
  
  <p>I am following this tutorial (which is for ubuntu): <a href="https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-14-04" rel="nofollow noreferrer">https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-14-04</a></p>
  
  <p>My config file looks like: myapp.conf</p>
  
  <pre><code>description "Gunicorn application server running myproject"
  
  start on runlevel [2345]
  stop on runlevel [!2345]
  
  respawn
  setuid user
  setgid www-data
  
  env PATH=/home/ec2-user/flask/venv/bin
  chdir /home/ec2-user/flask
  exec gunicorn --workers 3 --bind unix:app.sock -m 007 wsgi
  </code></pre>
  
  <p>My wsgi file looks like: wsgi.py</p>
  
  <pre><code>from app import application
  
  if __name__ == "__main__":
      application.run()
  </code></pre>
  
  <p>My actual application looks like: app.py</p>
  
  <pre><code>from flask import Flask
  application = Flask(__name__)
  
  @application.route("/")
  def hello():
      return ""Hello World"
  
  if __name__ == "__main__":
      application.run(host='0.0.0.0')
  </code></pre>
  
  <p>When I do a: </p>
  
  <pre><code>sudo start myapp
  </code></pre>
  
  <p>I get an error saying unknown job. What exactly do I have to do to get this running? Or is there a different way to make upstart scripts on Amazon Linux instances? Could someone please help</p>