title: How to correctly load Flask app module in uWSGI?
body: <p>[EDIT]</p>
  
  <p>I managed to load the flask app module by starting uwsgi from within the project folder. I now have a problem with nginx not having permission to the socket file though (scroll down to the end of the question). If anybody can help with that..?</p>
  
  <p>[/EDIT]</p>
  
  <p>Following <a href="http://vladikk.com/2013/09/12/serving-flask-with-nginx-on-ubuntu/" rel="nofollow">this tutorial</a> I'm trying to run my Flask website with <a href="http://uwsgi-docs.readthedocs.org/en/latest/" rel="nofollow">uWSGI</a> and <a href="http://nginx.org/" rel="nofollow">nginx</a>. When doing exactly as the tutorial says it works fine. I now want to run my own website though. And the structure of my own website project looks as follows:</p>
  
  <pre><code>myownproject
     |-app
         | -__init__.py
     |-run.py
     |-myownproject_nginx.conf
     |-myownproject_uwsgi.ini
  </code></pre>
  
  <p>in which <code>app</code> is loaded in <code>__init__.py</code> like this:</p>
  
  <pre><code>app = Flask(__name__)
  </code></pre>
  
  <p>and myownproject_uwsgi.ini looks like this:</p>
  
  <pre><code>[uwsgi]
  #application's base folder
  base = /home/kramer65/myownproject
  
  #python module to import
  app = app
  module = %(app)
  
  # I disabled these lines below because I don't use a venv (please don't ask)
  # home = %(base)/venv
  # pythonpath = %(base)
  
  #socket file's location
  socket = /home/kramer65/myownproject/%n.sock
  
  #permissions for the socket file
  chmod-socket    = 666
  
  #the variable that holds the flask application inside the imported module
  callable = app
  
  #location of log files
  logto = /var/log/uwsgi/%n.log
  </code></pre>
  
  <p>But when I run this:</p>
  
  <pre><code>$ uwsgi --ini /home/kramer65/myownproject/myownproject_uwsgi.ini
  [uWSGI] getting INI configuration from /home/kramer65/myownproject/myownproject_uwsgi.ini
  </code></pre>
  
  <p>I get the following logs in <code>/var/log/uwsgi/myownproject_uwsgi.log</code>:</p>
  
  <pre><code>*** Operational MODE: single process ***
  ImportError: No module named app
  unable to load app 0 (mountpoint='') (callable not found or import error)
  *** no app loaded. going in full dynamic mode ***
  *** uWSGI is running in multiple interpreter mode ***
  </code></pre>
  
  <p>Why doesn't uwsgi find my callable? And why is the <code>mountpoint</code> empty (<code>=''</code>)? What am I doing wrong here?</p>
  
  <p>Does anybody know how I can get this to work properly?</p>
  
  <p>[EDIT]</p>
  
  <p>Okay, I tried running <code>uwsgi --ini /home/kramer65/myownproject/myownproject_uwsgi.ini</code> from within the <code>myownproject</code> project folder, which solves this problem; it now finds the callable and that seems to work fine. </p>
  
  <p>I still get a 502 though, the next problem seems to be a permission problem with nginx not having permission to the socket file. <code>/var/log/nginx/error.log</code> says:</p>
  
  <blockquote>
    <p>2015/10/27 11:40:36 [crit] 14276#0: *1 connect() to
    unix:/home/kramer65/myownproject/myownproject_uwsgi.sock failed (13:
    Permission denied) while connecting to upstream, client:
    80.xxx.xxx.xxx, server: localhost, request: "GET / HTTP/1.1", upstream:
    "uwsgi://unix:/home/kramer65/myownproject/myownproject_uwsgi.sock:",
    host: "52.xx.xx.xxx"</p>
  </blockquote>
  
  <p>So I changed the <code>chmod-socket = 666</code> to <code>chmod-socket = 777</code>. When doing an <code>ls -l</code> I actually see the socket file having full permissions, but I still get the error I pasted above. </p>
  
  <p>Any ideas to get this working?</p>