12

Apache logs in mode debug:

[Tue Dec 21 11:36:33 2010] [info] [client 1.53.149.114] mod_wsgi (pid=24831, process='mysite', application='mysite.com|'): Loading WSGI script '/home/anhtran/webapps/mysite.com/django.wsgi'.
[Tue Dec 21 11:36:33 2010] [error] [client 1.53.149.114] Premature end of script headers: django.wsgi
[Tue Dec 21 11:36:33 2010] [notice] child pid 24831 exit signal Segmentation fault (11)
[Tue Dec 21 11:36:33 2010] [info] mod_wsgi (pid=24980): Attach interpreter ''.

My conf file:

WSGISocketPrefix /tmp/wsgi

<VirtualHost *:80>
   ServerName mysite.com
   ServerAlias www.mysite.com
   ServerAdmin [email protected]

   DocumentRoot /home/anhtran/webapps/mysite.com/public_html

   WSGIDaemonProcess mysite processes=5 threads=25
   WSGIProcessGroup mysite
   WSGIScriptAlias / /home/anhtran/webapps/mysite.com/django.wsgi

   LogLevel debug

   <Directory /home/anhtran/webapps/mysite.com/mysite>
      Order allow,deny
      Allow from all
   </Directory>

</VirtualHost>

Django works fine in a basic project without a data connection such as MySQLdb or sqlite3. I'm using CentOS 5 64 bit, apache 2.x, mod_wsgi 3.2. I think this is not a problem of Django, but I have no idea for it. Everybody can fix it? Help me. Thanks! :)

django.wsgi

#!/usr/local/bin/python
import os, site, sys

# add the virtual environment path
site.addsitedir('/home/anhtran/webapps/mysite.com/env/lib/python2.6/site-packages')
site.addsitedir('/home/anhtran/webapps/mysite.com/mysite')
site.addsitedir('/home/anhtran/webapps/mysite.com')

# fix markdown.py (and potentially others) using stdout
sys.stdout = sys.stderr

#Calculate the path based on the location of the WSGI script.
project = os.path.dirname(__file__)
workspace = os.path.dirname(project)
sys.path.append(workspace)

os.environ['PYTHON_EGG_CACHE'] = '/home/anhtran/webapps/mysite.com/.python-eggs'
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()

I've read some questions in this link: http://code.google.com/p/modwsgi/wiki/FrequentlyAskedQuestions But I still don't understand the solutions.

3
  • Could you post your django.wsgi file? Commented Dec 21, 2010 at 18:28
  • django.wsgi file has added. I hope it will help you make some ideas :( Commented Dec 21, 2010 at 19:19
  • I don't have any specific suggestions, but I found this link that might be helpful: htmlfixit.com/cgi-tutes/… Commented Dec 21, 2010 at 22:51

6 Answers 6

10

The daemon process crashed. See comments in the mod_wsgi FAQ about what causes crashes:

http://code.google.com/p/modwsgi/wiki/FrequentlyAskedQuestions

and follow links there.

Ultimately the cause can be many things, including loading incompatible mod_python at same time, using Python C extension module that doesn't work with sub interpreters, incompatible shared library versions used by Apache and/or extension modules in PHP etc.

Sign up to request clarification or add additional context in comments.

3 Comments

I had the same problem being caused by a Python C extension. I added "WSGIApplicationGroup %{GLOBAL}" to my Apache config and it solved the problem. The directive forces the WSGI application to be run within the very first Python sub interpreter, which eliminates the deadlocks that cause Apache to restart processes. You can read more about it on the Google Wiki
@Graham I have 66 lacs of line in log files. While reading this mod wsgi daemon process crashing.Please help to read large GB file in wsgi application.
@Mushir Create a new question, or if you think it is going to need a discussion, use the mod_wsgi mailing list instead. modwsgi.readthedocs.io/en/develop/finding-help.html
4

Finally, I found the solution. It's a problem of Multiple Python Versions: http://code.google.com/p/modwsgi/wiki/InstallationIssues#Multiple_Python_Versions.

Thanks all! :P

1 Comment

This was also my exact problem, the server was running Natty, which ships with Python 2.7, but installing mod_wsgi also installs python2.6, because that's the one that the module uses. By creating the virtual environment without an explicit python interpreter, it's assumed the system defaults (v2.7) which conflicts with the mod_wsgi requirement (v2.6). After recreate the environment but with the python2.6 executable, and the updated some path references, it worked.
4

I had a similar problem on django,apache2,mod_wsgi,python2.6 installed on a virtual machine. I solved the problem incerasing the ram assigned to the virtual machine.

I hope this will help.

1 Comment

Crashing because of OOM is definitely one of the reasons behind this unfriendly error message.
0

Try to delete this

WSGISocketPrefix /tmp/wsgi

And this

WSGIDaemonProcess mysite processes=5 threads=25
WSGIProcessGroup mysite

On my server it works.

1 Comment

with your way, it's no response. That means no error and no data :(
0

I am getting this same error, and while the underlying cause may be the multiple python versions, I have found that it is happening because of hung queries from Django to my MySQL server. If I run a

show processlist;

at the MySQL prompt, I see that queries are backing up in the queue. If I kill the query at the top, all other open processes immediately complete and my site comes back to life.

Hope this helps someone else. You can also run

show full processlist;

to see the exact query. In my case, it was a django select_related query that created tons of INNER JOIN clauses in the query.

See: http://dev.mysql.com/doc/refman/5.1/en/show-processlist.html

Comments

0

my same issue was resolved like this: remove cgi configure that was added by me someday:

AddHandler cgi-script .py

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.