mod_wsgi / mysql / python error --- stuck for days

I am running

Ubuntu - 9.04

Python 2.6.2

Django - 1.1.0

MySQL - 5.0

MySQLdb 1.2.3c

Apache 2.2.11 (Ubuntu)

mod_wsgi 2.5

Problem is that when I activate Apache and try using a Django app I get this error:

"

500 Internal Server Error

The server encountered an internal error or misconfiguration and was

unable to complete your request.

"

The django app are making use of MySQL database.

Strange thing is that

  • same Django app work fine if I run it via Django development server (not appache)

  • Other Django apps also works fine via apache / mod_wsgi as long as I don't use msql (I've tested apps with no databse or sqlite3)

Using Mysql via Python also appear to be working fine.

So – any ideas why the combination Apache / mod_wsgi > Django / mysql is not working but individual components are?

Some thoughts

MySQLdb

I did battle to get MySQLdb working.

import MySQLdb

get no error

MySQLdb.version_info

I still think problem is with MySQLdb although it is working by it self and with Django dev server

Python 2.6

I could move down to 2.5 and give it a go – hasn't done it yet

Can I run apache / mod_wsgi in "debug mode" and get more info on error?

Many Thanks

7 Replies

I generally use the cgitb module to collect tracebacks… this will spit out a more detailed error instead of a 500, and also (optionally) dump out a file. (Really handy if your users get the errors and you don't…)

Here's an example of it in use: http://hoopycat.com/cgi-bin/broken.cgi

hoopycat – thanks for quick response -- looks like a great feature.

I inserted:

import cgitb; cgitb.enable()

in my django.wsgi file (python) and my setup.py file.

No luck -- still Error 500 only.

If I comment out the following line in my settings.py file

DATABASE_ENGINE = 'mysql'

all is OK -- page displays fine.

The moment I add the above line (in settings.py) I get server 500 error.

Will try a few more options / google for idea.

Thanks

hoopycat – thanks for quick response -- looks like a great feature.

I inserted:

import cgitb; cgitb.enable()

in my django.wsgi file (python) and my setup.py file.

No luck -- still Error 500 only.

If I comment out the following line in my settings.py file

DATABASE_ENGINE = 'mysql'

all is OK -- page displays fine.

The moment I add the above line (in settings.py) I get server 500 error.

Will try a few more options / google for idea.

Thanks

Anything in your server error logs?

You said it works in 'runserver' mode?

@bosveld:

DATABASE_ENGINE = 'mysql'

According to;

http://docs.djangoproject.com/en/dev/intro/tutorial01/

in the section labeled "database setup", it states that you must supply more parameters than that one alone - for example login id and password, along with a database name, then run "python manage.py syncdb". I use the default sqlite3 database myself - just session data.

James

zunzun: I do specify the rest – just omitted in my post.

DATABASE_ENGINE = 'mysql'  
DATABASE_NAME = 'demo1'  
DATABASE_USER = 'myuser'            
DATABASE_PASSWORD = 'mypassword'    
DATABASE_HOST = '127.0.0.1'     # also tried blank & localhost
DATABASE_PORT = '' 

But all OK if I run using "python manage.py runserver 80"

Which make me think problem is not in settings.py

mwalling: In my Apache Logs

[notice] caught SIGTERM, shutting down

Still trying to puzzle out what this means…

Got problem solved.

Above problem was with Ubuntu 9.04

I moved to Debian 5.0 and all is working now.

Not 100% sure what main problem was – but Ubuntu 9.04 has Python 2.6 as standard and Debian got 2.5 (which I prefer).

I still think it was that.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct