Atma
Atma

Reputation: 29795

wsgi breaks on ec2 django installation

I'm getting the following error when testing a start django app: ImportError: No module named 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

my httpd.conf looks like this: LoadModule wsgi_module modules/mod_wsgi.so #loaded above

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>

My wsgi.py looks like:

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()

I installed mod_wsgi with the following command:

sudo yum install mod_wsgi

Does anyone know what I am doing wrong?

Upvotes: 0

Views: 81

Answers (1)

Atma
Atma

Reputation: 29795

sudo yum install mod_wsgi does not work. It has to be compiled on your instance. Here are the complete steps:

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

Upvotes: 0

Related Questions