mod_wsgi getting permission denied writing webapp/info.log

Asked by Joseph Schmoley

I've followed all instructions for installing graphite at http://readthedocs.org/docs/graphite/en/latest/install.html.

Machine: Ubuntu 11.10 Server x64

Ran all the installation scripts using sudo.

Got Apache2 running with the graphite vhost file that was under the examples directory.

Defined "graphite" in my DNS to point to the machine hosting Apache2 & graphite.

When I hit http://graphite I get a 500 error in browser and the following in /opt/graphite/storage/log/webapp/error.log:

[Tue Nov 08 23:28:16 2011] [error] [client 10.0.1.164] mod_wsgi (pid=9023): Target WSGI script '/opt/graphite/conf/graphite.wsgi' cannot be loaded as Python module.
[Tue Nov 08 23:28:16 2011] [error] [client 10.0.1.164] mod_wsgi (pid=9023): Exception occurred processing WSGI script '/opt/graphite/conf/graphite.wsgi'.
[Tue Nov 08 23:28:16 2011] [error] [client 10.0.1.164] Traceback (most recent call last):
[Tue Nov 08 23:28:16 2011] [error] [client 10.0.1.164] File "/opt/graphite/conf/graphite.wsgi", line 14, in <module>
[Tue Nov 08 23:28:16 2011] [error] [client 10.0.1.164] from graphite.logger import log
[Tue Nov 08 23:28:16 2011] [error] [client 10.0.1.164] File "/opt/graphite/webapp/graphite/logger.py", line 75, in <module>
[Tue Nov 08 23:28:16 2011] [error] [client 10.0.1.164] log = GraphiteLogger() # import-shared logger instance
[Tue Nov 08 23:28:16 2011] [error] [client 10.0.1.164] File "/opt/graphite/webapp/graphite/logger.py", line 40, in __init__
[Tue Nov 08 23:28:16 2011] [error] [client 10.0.1.164] self.infoHandler = Rotater(self.infoLogFile,when="midnight",backupCount=1)
[Tue Nov 08 23:28:16 2011] [error] [client 10.0.1.164] File "/usr/lib/python2.7/logging/handlers.py", line 171, in __init__
[Tue Nov 08 23:28:16 2011] [error] [client 10.0.1.164] BaseRotatingHandler.__init__(self, filename, 'a', encoding, delay)
[Tue Nov 08 23:28:16 2011] [error] [client 10.0.1.164] File "/usr/lib/python2.7/logging/handlers.py", line 65, in __init__
[Tue Nov 08 23:28:16 2011] [error] [client 10.0.1.164] logging.FileHandler.__init__(self, filename, mode, encoding, delay)
[Tue Nov 08 23:28:16 2011] [error] [client 10.0.1.164] File "/usr/lib/python2.7/logging/__init__.py", line 893, in __init__
[Tue Nov 08 23:28:16 2011] [error] [client 10.0.1.164] StreamHandler.__init__(self, self._open())
[Tue Nov 08 23:28:16 2011] [error] [client 10.0.1.164] File "/usr/lib/python2.7/logging/__init__.py", line 912, in _open
[Tue Nov 08 23:28:16 2011] [error] [client 10.0.1.164] stream = open(self.baseFilename, self.mode)
[Tue Nov 08 23:28:16 2011] [error] [client 10.0.1.164] IOError: [Errno 13] Permission denied: '/opt/graphite/storage/log/webapp/info.log'

When I check the permissions for /opt/graphite/storage/log/webapp/ it's root:root all the way up the tree. My question is should this directory where info.log is going to be written belong to the user/group that apache2 runs under? In Ubuntu's case it's www-data.

Did I make a mistake by running all the pkgs installation scripts using sudo?

Anyways, any help would be much appreciated.

Thanks in advance.

-Jac

Question information

Language:
English Edit question
Status:
Solved
For:
Graphite Edit question
Assignee:
No assignee Edit question
Solved by:
chrismd
Solved:
Last query:
Last reply:
Revision history for this message
Best chrismd (chrismd) said :
#1

Yes try chowning /opt/graphite/storage/logs/webapp to the apache user.

Revision history for this message
Joseph Schmoley (jacomoman78) said :
#2

Thanks chrismd, that solved my question.

Revision history for this message
Nicholas Leskiw (nleskiw) said :
#3

Technically, all of storage/whisper and the sqlite DB files should be owned by that user, not just the logs directories. Graphite will write new files and directories, so the dirs should be chowned as well.