我正在尝试使用mod_wsgi和apache2部署Django Web服务器,我收到内部服务器错误 .
[Sun Mar 29 16:13:00.382493 2015] [mpm_event:notice] [pid 1194:tid 139655348275072] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Sun Mar 29 16:13:00.382514 2015] [core:notice] [pid 1194:tid 139655348275072] AH00094: Command line: '/usr/sbin/apache2'
[Sun Mar 29 20:13:03.159156 2015] [:error] [pid 26383:tid 139655211136768] [remote 71.88.97.195:25099] mod_wsgi (pid=26383): Target WSGI script '/var/www/mbusuite/mbusuite/wsgi.py' cannot be loaded as Python module.
[Sun Mar 29 20:13:03.159199 2015] [:error] [pid 26383:tid 139655211136768] [remote 71.88.97.195:25099] mod_wsgi (pid=26383): Exception occurred processing WSGI script '/var/www/mbusuite/mbusuite/wsgi.py'.
[Sun Mar 29 20:13:03.159221 2015] [:error] [pid 26383:tid 139655211136768] [remote 71.88.97.195:25099] Traceback (most recent call last):
[Sun Mar 29 20:13:03.159258 2015] [:error] [pid 26383:tid 139655211136768] [remote 71.88.97.195:25099] File "/var/www/mbusuite/mbusuite/wsgi.py", line 16, in <module>
[Sun Mar 29 20:13:03.159317 2015] [:error] [pid 26383:tid 139655211136768] [remote 71.88.97.195:25099] application = get_wsgi_application()
[Sun Mar 29 20:13:03.159329 2015] [:error] [pid 26383:tid 139655211136768] [remote 71.88.97.195:25099] File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Sun Mar 29 20:13:03.159368 2015] [:error] [pid 26383:tid 139655211136768] [remote 71.88.97.195:25099] django.setup()
[Sun Mar 29 20:13:03.159379 2015] [:error] [pid 26383:tid 139655211136768] [remote 71.88.97.195:25099] File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
[Sun Mar 29 20:13:03.159415 2015] [:error] [pid 26383:tid 139655211136768] [remote 71.88.97.195:25099] apps.populate(settings.INSTALLED_APPS)
[Sun Mar 29 20:13:03.159427 2015] [:error] [pid 26383:tid 139655211136768] [remote 71.88.97.195:25099] File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 85, in populate
[Sun Mar 29 20:13:03.159563 2015] [:error] [pid 26383:tid 139655211136768] [remote 71.88.97.195:25099] app_config = AppConfig.create(entry)
[Sun Mar 29 20:13:03.159575 2015] [:error] [pid 26383:tid 139655211136768] [remote 71.88.97.195:25099] File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 87, in create
[Sun Mar 29 20:13:03.159654 2015] [:error] [pid 26383:tid 139655211136768] [remote 71.88.97.195:25099] module = import_module(entry)
[Sun Mar 29 20:13:03.159665 2015] [:error] [pid 26383:tid 139655211136768] [remote 71.88.97.195:25099] File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[Sun Mar 29 20:13:03.159708 2015] [:error] [pid 26383:tid 139655211136768] [remote 71.88.97.195:25099] __import__(name)
[Sun Mar 29 20:13:03.159739 2015] [:error] [pid 26383:tid 139655211136768] [remote 71.88.97.195:25099] ImportError: No module named storage
我的apache配置文件是:
<VirtualHost *:80>
ServerName mbusuite.duckdns.org
WSGIDaemonProcess mbusuite.duckdns.org python-path=/var/www/mbusuite:/usr/local/lib/python2.7/site-packages
WSGIProcessGroup mbusuite.duckdns.org
WSGIScriptAlias / /var/www/mbusuite/mbusuite/wsgi.py process-group=mbusuite.duckdns.org
ServerAdmin mbu@wpi.edu
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
#<Directory /var/www/mbusuite/static>
# Require all granted
#</Directory>
#<Directory /var/www/mbusuite/core>
# Require all granted
#</Directory>
#<Directory /var/www/mbusuite/templates>
# Require all granted
#</Directory>
<Directory /var/www/mbusuite/>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
而且wsgi.py是
"""
WSGI config for mbusuite project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/
"""
import os
import sys
os.environ["DJANGO_SETTINGS_MODULE"] = "mbusuite.settings"
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
我不太确定这是权限问题还是配置问题 . 任何帮助都会很棒 .
1 回答
我不认为您可以在WSGIScriptAlias指令上指定进程组,并且您的python-path指令必须与您在wsgi.py文件中的指令匹配(即
DJANGO_SETTINGS_MODULE
必须可从您指定的python路径导入) . 因为's usually Apache'的docroot区域,所以你不应该在/ var / www下使用你的源代码 - 并且你不希望任何服务原始源的可能性 . 就像是:应该使用您当前的wsgi.py(您可能还需要声明一个docroot - 您可以使用它来例如提供
favicon.ico
文件;-)