Setting write permissions in Django log files

I have a set of Django log files for which I have an appropriate logger designed to record messages. However, every time it creates a new log file, the file permissions prevent me from starting the shell and sometimes cause problems with apache.

I ran chmod -Rv 777 in a directory that sets all the permissions so that we can do what we like, but the next log file created returns to some default values.

How to set permissions for generated log files

Mark

+6
source share
2 answers

Permissions on files created by a specific user depend on which mask is set for that specific user.

Now you need to set the appropriate permissions for those who start the apache service

ps -aux | grep apache | awk '{ print $1 }' 

Then for that specific user using apache (www-data?)

 sudo chown -R your_user:user_running_apache directory 

where the directory is the root directory of your django application. To ensure that all files that will be added to this directory in the future, the correct permissions are executed:

 sudo chmod -R g+s directory 
+3
source

I encountered the same problem - I had problems starting the shell and celery due to permissions of the rotary log files. I run my django project through uwsgi (which works as the www-data user) - so I processed it by setting umask for it ( http://uwsgi-docs.readthedocs.org/en/latest/Options.html#umask ).

I also use buildout, so my fix is ​​as follows:

 [uwsgi] recipe = buildout.recipe.uwsgi xml-socket = /tmp/uwsgi.sock xml-master = True xml-chmod-socket = 664 xml-umask = 0002 xml-workers = 3 xml-env = ... xml-wsgi-file = ... 

After these access rights to the journal became 664, members of the www-data group can also write to it.

+1
source

Source: https://habr.com/ru/post/953437/


All Articles