2010-11-04 17 views
8

$ sudoDjango uygulamam neden günlük dosyasına yazmıyor?

* Restarting web server apache2 
... waiting . ...done. 

kullanıcı adı @ sunucuadı'nı Per Kasım yeniden /etc/init.d/apache2 04 18:54:37 ~/public_html/IDM_app
$ sudo kuyruk -n 60/var// apache2/error.log

[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38] mod_wsgi (pid=28760): Exception occurred processing WSGI script '/home/username/public_html/idm.wsgi'. 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38] Traceback (most recent call last): 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38] File "/usr/local/lib/python2.7/site-packages/Django-1.2.3-py2.7.egg/django/core/handlers/wsgi.py", line 230, in __call__ 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38]  self.load_middleware() 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38] File "/usr/local/lib/python2.7/site-packages/Django-1.2.3-py2.7.egg/django/core/handlers/base.py", line 33, in load_middleware 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38]  for middleware_path in settings.MIDDLEWARE_CLASSES: 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38] File "/usr/local/lib/python2.7/site-packages/Django-1.2.3-py2.7.egg/django/utils/functional.py", line 276, in __getattr__ 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38]  self._setup() 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38] File "/usr/local/lib/python2.7/site-packages/Django-1.2.3-py2.7.egg/django/conf/__init__.py", line 40, in _setup 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38]  self._wrapped = Settings(settings_module) 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38] File "/usr/local/lib/python2.7/site-packages/Django-1.2.3-py2.7.egg/django/conf/__init__.py", line 73, in __init__ 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38]  mod = importlib.import_module(self.SETTINGS_MODULE) 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38] File "/usr/local/lib/python2.7/site-packages/Django-1.2.3-py2.7.egg/django/utils/importlib.py", line 35, in import_module 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38]  __import__(name) 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38] File "/home/username/public_html/IDM_app/settings.py", line 60, in <module> 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38]  from settings_local import * 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38] File "/home/username/public_html/IDM_app/settings_local.py", line 1, in <module> 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38]  from settings_Slicehost_idm import * 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38] File "/home/username/public_html/IDM_app/settings_Slicehost_idm.py", line 12, in <module> 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38]  format='%(pathname)s TIME: %(asctime)s MSG: %(filename)s:%(funcName)s:%(lineno)d %(message)s', 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38] File "/usr/local/lib/python2.7/logging/__init__.py", line 1500, in basicConfig 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38]  hdlr = FileHandler(filename, mode) 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38] File "/usr/local/lib/python2.7/logging/__init__.py", line 889, in __init__ 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38]  StreamHandler.__init__(self, self._open()) 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38] File "/usr/local/lib/python2.7/logging/__init__.py", line 908, in _open 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38]  stream = open(self.baseFilename, self.mode) 
[Thu Nov 04 18:54:27 2010] [error] [client 8.17.58.38] IOError: [Errno 13] Permission denied: '/home/username/public_html/IDM_app/log/django.osqa.log' 
[Thu Nov 04 18:54:36 2010] [notice] caught SIGTERM, shutting down 
[Thu Nov 04 18:54:37 2010] [notice] Apache/2.2.14 (Ubuntu) mod_wsgi/3.3 Python/2.7 configured -- resuming normal operations 

kullanıcı adı @ servername Per 4 Kasım 18:54:42 ~/public_html/IDM_app
$ ls-l/home/username/public_htm log l/IDM_app/log/django.osqa.log

-rw-r--r-- 1 username 0 Nov 4 18:24 /home/username/public_html/IDM_app/log/django.osqa.log 

kullanıcı adı @ servername Per 4 Kasım 19:08:41 ~/public_html/IDM_app
** $ ls-l ~/public_html/idm.wsgi **

-rw-r--r-- 1 username 222 Nov 4 18:53 /home/username/public_html/idm.wsgi 

kullanıcı adı @ servername Per 4 Kasım 19:10:50 ~/public_html/IDM_app
$ cat ~/public_html/idm.wsgi

import os 
import sys 

sys.path.append('/home/username/public_html/IDM_app/') 

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' 

import django.core.handlers.wsgi 

application = django.core.handlers.wsgi.WSGIHandler() 

kullanıcı adı @ servername Per 4 Kasım 19:11:02 ~/public_html/IDM_app $ benkimim

username 

Apache2 Sanal Sunucu kurulum dosyasını @ ~/public_html/idm.wsgi kullanıyorsa ne Kullanıcı sistem, günlük dosyası log/django.osqa.log yazmaya çalıştığını düşünüyor mu?

Django uygulamam neden günlük dosyasına yazmıyor?

cevap

17

Apaçi en muhtemelen günlük dosyasına yazma erişimi yok yani apache kullanıcı olarak çalışan. Her şey için okuma izinleri olan wsgi dosyasını okumak zorunda olduğu için iyi çalışır. chmod a+w django.osqa.log veya chown <apache-user> django.osqa.log.

Not: tercih edilen bir yöntem chown dosya olacaktır.

Not 2: Bu dağıtıma bağımlı, ama bu Ubuntu-y görünüyor, çünkü apache kullanıcı www-data olacaktır.

+4

'chogrr' yerine' chgrp' kullanmak da bir seçenektir. –

+0

Veya daha da iyisi, ACL'ler –

+0

'u daha iyi kullanmak için 'apache', 'www-data' ve' daemon 'kullanıcılarını kontrol etmek ister ... – nicorellius

İlgili konular