Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to deploy a Flask app using apache and mod_wsgi. I've been following the directions here. The simple hello-world example that is on that site works perfectly.

When I try to substitute my own Flask app, I get a 500 Internal Server Error. This is the output from the apache logs:

[Wed Oct 02 14:50:26 2013] [info] [client 68.184.201.104] mod_wsgi (pid=4881, process='', application='toptencrop.com|'): Loading WSGI script '/var/www/top_ten_crop/crop.wsgi'.
[Wed Oct 02 14:50:26 2013] [error] [client 68.184.201.104] mod_wsgi (pid=4881): Target WSGI script '/var/www/top_ten_crop/crop.wsgi' cannot be loaded as Python module.
[Wed Oct 02 14:50:26 2013] [error] [client 68.184.201.104] mod_wsgi (pid=4881): Exception occurred processing WSGI script '/var/www/top_ten_crop/crop.wsgi'.
[Wed Oct 02 14:50:26 2013] [error] [client 68.184.201.104] Traceback (most recent call last):
[Wed Oct 02 14:50:26 2013] [error] [client 68.184.201.104]   File "/var/www/top_ten_crop/crop.wsgi", line 9, in <module>
[Wed Oct 02 14:50:26 2013] [error] [client 68.184.201.104]     from crop import app as application
[Wed Oct 02 14:50:26 2013] [error] [client 68.184.201.104] ImportError: No module named crop

Things I have tried

  • I've set the permissions to 0644
  • Recompiled mod_wsgi to make sure it was the same version of python
  • Made sure that if I enter the sys.path.insert(0,'/var/www/top_ten_crop') line, I can import my app from anywhere.
  • Checked all the paths in the config files over and over again.

I would appreciate any advice for what to try. Here are the relevant files:

/var/www/top_ten_crop/crop.wsgi:

#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,'/var/www/top_ten_crop')

from crop import app as application
application.secret_key = 'secret'```

/etc/apache2/sites-available/top_ten_crop

<VirtualHost *:80>
                ServerName toptencrop.com
                ServerAdmin brian.schiller@nielsen.com
                WSGIScriptAlias / /var/www/top_ten_crop/crop.wsgi
                WSGIPassAuthorization On
                <Directory /var/www/top_ten_crop/crop>
                        Order allow,deny
                        Allow from all
                </Directory>
                Alias /static /var/www/top_ten_crop/crop/static
                <Directory /var/www/top_ten_crop/crop/static/>
                        Order allow,deny
                        Allow from all
                </Directory>
                ErrorLog ${APACHE_LOG_DIR}/error.log
                LogLevel debug
                CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

output from tree

top_ten_crop/
├── bootstrap.sh
├── config_files
│   ├── celeryd
│   └── mod_wsgi_config
├── crop
│   ├── celery.py
│   ├── constants.py
│   ├── forms.py
│   ├── helpers.py
│   ├── __init__.py
│   ├── models.py
│   ├── mturkcore.py
│   ├── mturk.py
│   ├── static
│   │   ├── css
│   │   │   ├── bootstrap.css
│   │   │   ├── bootstrap.min.css
│   │   │   ├── bootstrap-responsive.css
│   │   │   ├── bootstrap-responsive.min.css
│   │   │   ├── Jcrop.gif
│   │   │   ├── jquery.Jcrop.css
│   │   │   ├── jquery.Jcrop.min.css
│   │   │   └── main.css
│   │   ├── img
│   │   │   ├── glyphicons-halflings.png
│   │   │   ├── glyphicons-halflings-white.png
│   │   │   └── worker_id.jpg
│   │   └── js
│   │       ├── bootstrap.js
│   │       ├── bootstrap.min.js
│   │       ├── jquery.color.js
│   │       ├── jquery.Jcrop.js
│   │       ├── jquery.Jcrop.min.js
│   │       └── jquery.min.js
│   ├── tasks.py
│   ├── templates
│   │   ├── 404.html
│   │   ├── base.html
│   │   ├── boot.html
│   │   ├── example.html
│   │   ├── helpers.html
│   │   ├── images.html
│   │   ├── image_status.html
│   │   ├── job.html
│   │   ├── list_comments.html
│   │   ├── list_examples.html
│   │   ├── list_users.html
│   │   ├── login.html
│   │   ├── new_example.html
│   │   ├── register.html
│   │   ├── review_crop.html
│   │   ├── review_validation.html
│   │   ├── selection_job.html
│   │   └── validation_job.html
│   └── views.py
├── crop.wsgi
├── db_create.py
├── interactive_bootstrap.py
├── README.md
├── runserver.py
├── selection_hit.html
├── top10-crop.log
├── Vagrantfile
└── validation_hit.html

7 directories, 57 files
share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.