2

We’re running some Laravel commands using Supervisor on our server. Each program writes to a log file in storage/logs.

The issue is that whenever a Supervisor rotates or creates a new log file, it’s being created with restrictive permissions -rw-r--r--.

Note, this one is created by the supervisor:

-rw-r--r-- 1 root     root       149 Sep 10 07:25 laravel-2025-09-10.log

What we need:

All log files should always be created with 0666 or 0777 permissions.

The log files should not be owned by root, but instead by the www-data user.

We dream of a listing like this but with the appropriate user and mode:

-rwxrwxrwx 1 root     root      5187 Aug 28 23:00 laravel-2025-08-28.log
-rwxrwxrwx 1 root     root      6780 Aug 29 23:00 laravel-2025-08-29.log
-rwxrwxrwx 1 root     root      7087 Aug 30 23:01 laravel-2025-08-30.log
-rwxrwxrwx 1 root     root      7295 Aug 31 23:00 laravel-2025-08-31.log
-rwxrwxrwx 1 root     root      8282 Sep  1 23:00 laravel-2025-09-01.log
-rwxrwxrwx 1 root     root      8282 Sep  2 23:00 laravel-2025-09-02.log
-rwxrwxrwx 1 root     root      6966 Sep  3 23:00 laravel-2025-09-03.log
-rwxrwxrwx 1 root     root      7295 Sep  4 23:00 laravel-2025-09-04.log
-rwxrwxrwx 1 root     root      9690 Sep  5 23:00 laravel-2025-09-05.log
-rwxrwxrwx 1 root     root      8533 Sep  6 23:00 laravel-2025-09-06.log
-rwxrwxrwx 1 root     root      7771 Sep  7 23:00 laravel-2025-09-07.log
-rwxrwxrwx 1 root     root      6801 Sep  8 23:00 laravel-2025-09-08.log
-rwxrwxrwx 1 root     root       574 Sep  9 14:54 laravel-2025-09-09.log

How can we configure Supervisor (or the environment) so that new log files created by these processes always use those permissions?

4
  • 4
    If you want the log files (and processes) to be owned by www-data, configure Supervisor to drop privileges. user=www-data = This ensure that the worker and any log files Supervisor rotates are created as www-data:www-data Commented Sep 10 at 8:47
  • 3
    Supervisor applies a umask when creating log files. By default it’s 022 (→ 644). umask=0000 → new files get 666 and directories 777. Commented Sep 10 at 8:52
  • What @KamranKhalid has comment, additionally don't ask for the mode, but correct the user first. It looks like it is is specific to the application (not the system, root is for the system and having logs files owned by root under 777 is a grave security issue, we normally use it to hack the computer then --- from only entering via PHP) Commented Sep 11 at 4:26
  • 1
    Please add the relevant part of your supervisor configuration file to your question and double-check if any of the links I edited in actually make sense. Commented Sep 11 at 4:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.