Anton Zhernov
Anton Zhernov

Reputation: 41

apache2 + django + mod_wsgi doesn't respond

I'm trying to deploy my working django app using apache2 + mod_wsgi module. This is my apache configuration:

anton@ru:~$ cat /etc/apache2/sites-available/default
Alias /static/ /home/anton/mysite/static/

<Directory /home/anton/mysite/static>
Order deny,allow
Allow from all
</Directory>

WSGIScriptAlias / /home/anton/mysite/mysite/wsgi.py

<Directory /home/anton/mysite>
Order allow,deny
Allow from all
</Directory>

and WCGI configuration:

anton@ru:~$ cat /home/anton/mysite/mysite/wsgi.py
import os
import sys
sys.path.append('/home/anton/mysite')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Using debug output (print 'bla-bla') I found out that wsgi.py works. But then http request doesn't get any response from apache. Could you please help me to understand why? Thanks!

UPDATE: I've turned logs on like this:

ErrorLog /home/anton/error.log
CustomLog /home/anton/custom.log combined

Here is what happens in error log when reloading the service:

[Wed Nov 06 05:43:14 2013] [notice] Graceful restart requested, doing restart
[Wed Nov 06 05:43:14 2013] [warn] NameVirtualHost *:80 has no VirtualHosts
[Wed Nov 06 05:43:14 2013] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Wed Nov 06 05:43:14 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Wed Nov 06 05:43:14 2013] [notice] Apache/2.2.22 (Debian) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations

When requesting "mysite.com/" nothing happens in error.log and custom.log. Static data works:

85.141.191.57 - - [06/Nov/2013:05:44:37 -0500] "GET /static/main.css HTTP/1.1" 304 213 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36"
85.141.191.57 - - [06/Nov/2013:05:44:38 -0500] "GET /static/main.css HTTP/1.1" 304 212 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36"

SOLUTION: The problem here was that python version didn't match the version of python mod_wsgi was compiled for. I built mod_wsgi from sources and that solved my problem.

Upvotes: 0

Views: 501

Answers (1)

Graham Dumpleton
Graham Dumpleton

Reputation: 58523

Try adding:

WSGIApplicationGroup %{GLOBAL}

For why read:

In general it is also recommended that mod_wsgi daemon mode be used.

although that shouldn't be the issue here.

Upvotes: 1

Related Questions