我正在尝试使用apache和mod_wsgi部署一个Flask应用程序。 我一直在这里跟随方向。 在该网站上的简单的hello-world示例完美地工作。
当我尝试replace我自己的Flask应用程序时,出现500 Internal Server Error 。 这是apache日志的输出:
[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
sys.path.insert(0,'/var/www/top_ten_crop')行,我可以从任何地方导入我的应用程序。 我将不胜感激任何尝试的build议。 这里是相关的文件:
#!/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'```
<VirtualHost *:80> ServerName toptencrop.com ServerAdmin [email protected] 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>
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