title: Running Flask on Apache - CentOS
body: <p>I setup a very simple flask application to test a deployment in Apache on CentOS 6 but I'm getting the follow error:</p>
  
  <pre><code>[Sat Apr 26 12:44:20 2014] [error] mod_wsgi (pid=29782): Target WSGI script '/var/www/html/sites/rtdsllc/rtdsllc.wsgi' cannot be loaded as Python module.
  [Sat Apr 26 12:44:20 2014] [error] mod_wsgi (pid=29782): Exception occurred processing WSGI script '/var/www/html/sites/rtdsllc/rtdsllc.wsgi'.
  [Sat Apr 26 12:44:20 2014] [error] Traceback (most recent call last):
  [Sat Apr 26 12:44:20 2014] [error] File "/var/www/html/sites/rtdsllc/rtdsllc.wsgi", line 10, in &lt;module&gt;
  [Sat Apr 26 12:44:20 2014] [error]     from rtdsllc import app as application
  [Sat Apr 26 12:44:20 2014] [error] ImportError: cannot import name app
  </code></pre>
  
  <p>This is my wsgi file:</p>
  
  <pre><code>activate_this = '/var/www/virtualenvs/default/bin/activate_this.py'
  execfile(activate_this, dict(__file__=activate_this))
  
  path = '/var/www/html/sites/rtdsllc'
  
  import sys
  if path not in sys.path:
      sys.path.append(path)
  
  from rtdsllc import app as application
  </code></pre>
  
  <p>Here is my virtual host config:</p>
  
  <pre><code>WSGISocketPrefix run/wsgi
  
  &lt;VirtualHost *:8086&gt;
  
      WSGIDaemonProcess rtdsllc user=apache group=apache threads=5
      WSGIScriptAlias /test /var/www/html/sites/rtdsllc/rtdsllc.wsgi
  
      ErrorLog logs/rtdsllc-error_log
      CustomLog logs/rtdsllc-access_log common
  
      &lt;Directory /var/www/html/sites/rtdsllc/rtdsllc&gt;
          WSGIProcessGroup rtdsllc
          WSGIApplicationGroup %{GLOBAL}
          Order deny,allow
          Allow from all
      &lt;/Directory&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>Here is my flask application:</p>
  
  <pre><code>from flask import Flask, render_template
  
  app = Flask(__name__)      
  
  @app.route('/')
  def home():
    return render_template('index.html')
  
  if __name__ == '__main__':
    app.run(debug=False)
  </code></pre>
  
  <p>And finally here is my folder structure:</p>
  
  <pre><code>rtdsllc/
  ├── rtdsllc
  │   ├── __init__.py
  │   ├── routes.py
  │   ├── static
  │   │   ├── css
  │   │   ├── img
  │   │   └── js
  │   └── templates
  │       ├── base.html
  │       └── index.html
  └── rtdsllc.wsgi
  </code></pre>
  
  <p>What gives? I've tried various combinations of settings to no avail. What is the proper way of setting up a Flask app in apache?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p><code>ls -las rtdsllc/rtdsllc</code>:</p>
  
  <pre><code>4 drwxr-xr-x. 4 apache apache 4096 Apr 26 13:07 .
  4 drwxr-xr-x. 3 apache apache 4096 Apr 25 22:54 ..
  0 -rw-r--r--. 1 apache apache    0 Apr 25 20:57 __init__.py
  4 -rw-r--r--. 1 apache apache  134 Apr 25 22:55 __init__.pyc
  4 -rw-r--r--. 1 apache apache  190 Apr 26 12:48 routes.py
  4 -rw-r--r--. 1 apache apache  521 Apr 26 13:07 routes.pyc
  4 drwxr-xr-x. 5 apache apache 4096 Apr 25 20:14 static
  4 drwxr-xr-x. 2 apache apache 4096 Apr 25 20:19 templates
  </code></pre>