我使用Django 1.6和Apache爲我的網站,在第一服務器運作良好,我能夠成功去我的網頁,但我跑得後:的Django + Apache的內部服務器錯誤:權限被拒絕
git reset --hard HEAD^
在我的/ var/www/html等/ mysite的倉庫,這表明內部服務器錯誤在瀏覽器中,我在錯誤日誌中有這樣的:
[Thu Jun 09 16:28:32 2016] [info] mod_wsgi (pid=15479): Create interpreter 'www.XXX.XXX|'.
[Thu Jun 09 16:28:32 2016] [info] mod_wsgi (pid=15479): Adding '/var/www/html/mysite' to path.
[Thu Jun 09 16:28:32 2016] [info] mod_wsgi (pid=15479): Adding '/usr/local/lib/python2.7/site-packages' to path.
[Thu Jun 09 16:28:32 2016] [error] [client 10.192.76.11] mod_wsgi (pid=15479): Exception occurred processing WSGI script '/var/www/html/mysite/mysite/wsgi.py'.
[Thu Jun 09 16:28:32 2016] [error] [client 10.192.76.11] Traceback (most recent call last):
[Thu Jun 09 16:28:32 2016] [error] [client 10.192.76.11] File "/usr/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 187, in __call__
[Thu Jun 09 16:28:32 2016] [error] [client 10.192.76.11] self.load_middleware()
[Thu Jun 09 16:28:32 2016] [error] [client 10.192.76.11] File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 44, in load_middleware
[Thu Jun 09 16:28:32 2016] [error] [client 10.192.76.11] for middleware_path in settings.MIDDLEWARE_CLASSES:
[Thu Jun 09 16:28:32 2016] [error] [client 10.192.76.11] File "/usr/local/lib/python2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__
[Thu Jun 09 16:28:32 2016] [error] [client 10.192.76.11] self._setup(name)
[Thu Jun 09 16:28:32 2016] [error] [client 10.192.76.11] File "/usr/local/lib/python2.7/site-packages/django/conf/__init__.py", line 50, in _setup
[Thu Jun 09 16:28:32 2016] [error] [client 10.192.76.11] self._configure_logging()
[Thu Jun 09 16:28:32 2016] [error] [client 10.192.76.11] File "/usr/local/lib/python2.7/site-packages/django/conf/__init__.py", line 80, in _configure_logging
[Thu Jun 09 16:28:32 2016] [error] [client 10.192.76.11] logging_config_func(self.LOGGING)
[Thu Jun 09 16:28:32 2016] [error] [client 10.192.76.11] File "/usr/local/lib/python2.7/logging/config.py", line 794, in dictConfig
[Thu Jun 09 16:28:32 2016] [error] [client 10.192.76.11] dictConfigClass(config).configure()
[Thu Jun 09 16:28:32 2016] [error] [client 10.192.76.11] File "/usr/local/lib/python2.7/logging/config.py", line 576, in configure
[Thu Jun 09 16:28:32 2016] [error] [client 10.192.76.11] '%r: %s' % (name, e))
[Thu Jun 09 16:28:32 2016] [error] [client 10.192.76.11] ValueError: Unable to configure handler 'file': [Errno 13] Permission denied: '/debug.log'
我看到它是「權限不足」,所以我ve run:
sudo chown -R www-data:www-data mysite
而且也:
sudo chmod -R 755 mysite
但它仍然沒有工作,我甚至改變了persmission到777
整個html
目錄,但它是沒有用的。 我不明白爲什麼出現許可錯誤,是否有與我運行的git命令相關的任何內容?
PS:我沒有在我的settings.py所有/debug.log
提到的,我寫道:
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': 'debug.log',
},
},
'loggers': {
'django.request': {
'handlers': ['file'],
'level': 'DEBUG',
'propagate': True,
},
},
}
什麼是設置中的LOG_ROOT?我覺得你的應用程序試圖訪問絕對目錄'/ debug.log',它是你的Linux機器的基本目錄。如果您的設置在回購中被跟蹤,請嘗試'git blame settings.py'並查看更改。 –
好吧,我沒有在settings.py –
中添加'LOG_ROOT'不要登錄到單獨的文件。登錄到控制檯處理程序並使mod_wsgi捕獲Django日誌輸出並將其發送到Apache錯誤日誌中。這是更好的方式。查看http://stackoverflow.com/questions/37736077/log-all-requests-to-file-django總之,問題是你不能使用相對路徑作爲日誌,因爲默認的當前工作目錄可能是任何東西,如果root目錄不可寫。 –