| Author |
Message |
bosveld
Joined: 20 May 2009
Posts: 7
|
| Posted: Wed May 20, 2009 1:15 pm Post subject: 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 |
|
| Back to top |
|
hoopycat
Joined: 30 Aug 2008
Posts: 1286
Location: Rochester, New York
|
| Posted: Wed May 20, 2009 1:25 pm Post subject: |
|
|
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 |
|
| Back to top |
|
bosveld
Joined: 20 May 2009
Posts: 7
|
| Posted: Wed May 20, 2009 2:23 pm Post subject: |
|
|
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 |
|
| Back to top |
|
bosveld
Joined: 20 May 2009
Posts: 7
|
| Posted: Wed May 20, 2009 2:39 pm Post subject: |
|
|
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 |
|
| Back to top |
|
mwalling
Joined: 10 Dec 2007
Posts: 335
|
| Posted: Wed May 20, 2009 3:05 pm Post subject: |
|
|
Anything in your server error logs?
You said it works in 'runserver' mode? |
|
| Back to top |
|
zunzun
Joined: 18 Feb 2005
Posts: 442
Location: Birmingham, Alabama USA
|
| Posted: Thu May 21, 2009 5:13 am Post subject: |
|
|
bosveld wrote: 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 |
|
| Back to top |
|
bosveld
Joined: 20 May 2009
Posts: 7
|
| Posted: Thu May 21, 2009 9:09 am Post subject: |
|
|
zunzun: I do specify the rest -- just omitted in my post.
Code:
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
Code:
[notice] caught SIGTERM, shutting down
Still trying to puzzle out what this means... |
|
| Back to top |
|
bosveld
Joined: 20 May 2009
Posts: 7
|
| Posted: Sat May 23, 2009 6:03 pm Post subject: |
|
|
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. |
|
| Back to top |
|
| |