我在测试启动django应用时遇到以下错误:ImportError:没有名为django.core.wsgi的模块
[Fri Feb 26 23:23:33 2016] [error] [client 100.9.129.136] mod_wsgi (pid=25312): Target WSGI script '/var/www/html/app_mgmt/app_core/wsgi.py' cannot be loaded as Python module.
[Fri Feb 26 23:23:33 2016] [error] [client 100.9.129.136] mod_wsgi (pid=25312): Exception occurred processing WSGI script '/var/www/html/app_mgmt/app_core/wsgi.py'.
[Fri Feb 26 23:23:33 2016] [error] [client 100.9.129.136] Traceback (most recent call last):
[Fri Feb 26 23:23:33 2016] [error] [client 100.9.129.136] File "/var/www/html/app_mgmt/app_core/wsgi.py", line 16, in <module>
[Fri Feb 26 23:23:33 2016] [error] [client 100.9.129.136] from django.core.wsgi import get_wsgi_application
[Fri Feb 26 23:23:33 2016] [error] [client 100.9.129.136] ImportError: No module named django.core.wsgi
我的httpd.conf看起来像这样: LoadModule wsgi_module modules / mod_wsgi.so #loaded上面
NameVirtualHost *:80
WSGIScriptAlias / /var/www/html/app_mgmt/app_core/wsgi.py
WSGIPythonPath /var/www/html/app_mgmt
<Directory /var/www/html/app_mgmt>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
我的wsgi.py看起来像:
import os
import sys
sys.path.append("/var/www/html/app_mgmt")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app_mgmt.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
我使用以下命令安装了mod_wsgi:
sudo yum install mod_wsgi
有谁知道我做错了什么?
答案 0 :(得分:0)
sudo yum install mod_wsgi
不起作用。它必须在您的实例上编译。以下是完整的步骤:
sudo yum install httpd httpd-devel
sudo yum install mysql mysql-server
sudo pip install django
sudo yum group install "Development Tools"
download the latest version of modwsgi here: http://code.google.com/p/modwsgi/downloads/list
https://code.google.com/archive/p/modwsgi/wikis/QuickInstallationGuide.wiki this is a good ref
tar xvfz mod_wsgi-X.Y.tar.gz
cd into mod_wsgi
./configure
make
make install
pip install MySQL-python