1

Im using centos6 machine to deploy my django project. and when i use django's default db setting with sqlite3 as below, it causes no problem.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

but when i try to use mysql for spatial data, make settings as below,

DATABASES = {
    'default': {
        'ENGINE': 'django.contrib.gis.db.backends.mysql',
        'NAME': 'dbname',
        'USER': 'username',
        'PASSWORD': 'userpassword',
        'HOST': 'localhost',
    }
}

it causes 500 internal server error with following apache2 error log

mod_wsgi (pid=14782): Target WSGI script '/home/swelite/www/travel/travel/wsgi.py' cannot be loaded as Python module.
mod_wsgi (pid=14782): Exception occurred processing WSGI script '/home/swelite/www/travel/travel/wsgi.py'.
Traceback (most recent call last):
File "/home/swelite/www/travel/travel/wsgi.py", line 18, in <module>
application = get_wsgi_application()
File "/usr/local/lib/python2.7/site-packages/Django-1.7.4-py2.7.egg/django/core/wsgi.py", line 14, in get_wsgi_application
django.setup()
File "/usr/local/lib/python2.7/site-packages/Django-1.7.4-py2.7.egg/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/site-packages/Django-1.7.4-py2.7.egg/django/apps/registry.py", line 78, in populate
raise RuntimeError("populate() isn't reentrant")
RuntimeError: populate() isn't reentrant

so i had supposed there might be problem with mysql and django's connection, but after i made models and do migrate with root@, i see mysql database are modified. So i think there might be some problem with apache that trying to use mysql db as settings.py says but can't find what is wrong.


edit1. I thought that, codes doesn't cause any error itself, since when i run

./manage.py runserver

it causes no error while when i add wrong db info, it caused error. So i supposed it could be a permission problem of apache and mysql.

Since there was no problem of sqlite3, I found my db.sqlite3 file permission was

-rw-r--r-- 1 root username 36864 2015-02-11 00:22 db.sqlite3

but my mysql's django database files' permission setting was

-rw-rw---- 1 mysql mysql     0 2015-02-12 01:13 auth_group.MYD

and apache uses user 'apache'. can this means that when my apache user 'apache' tries to access mysql, there occurs problem while 'localhost' does not?

edit2

Okay, I have to approve that i was stupid. It was a permission problem basically, but not related to mysql and apache user permission setting.

It was about permission setting on .python-eggs/

So what i did to solve this problem is to set

mkdir path/to/somewhere/error_logs/says/.python-eggs
chmod 777 -R path/to/somewhere/error_logs/says/.python-eggs

But still curiosity remains. Why the problem didn't occur when i was using sqlite3 instead mysql?

forsythia
  • 265
  • 1
  • 2
  • 5

1 Answers1

0

Okay, I have to approve that i was stupid. It was a permission problem basically, but not related to mysql and apache user permission setting.

It was about permission setting on .python-eggs/

So what i did to solve this problem is to set

mkdir path/to/somewhere/error_logs/says/.python-eggs
chmod 777 -R path/to/somewhere/error_logs/says/.python-eggs

But still curiosity remains. Why the problem didn't occur when i was using sqlite3 instead mysql?

forsythia
  • 265
  • 1
  • 2
  • 5