My apache server puts the logfile for my project under


I set the user and group to the ones of my project (foo:www-data) and I even tried to chmod to 777 (i know that it is a risk, but it is just a local VM), but if I try to access it, then I still get Permission Denied

tail -f /var/log/apache2/foo_error.log
tail: cannot open '/var/log/apache2/foo_error.log' for reading: Permission denied
tail: no files remaining

The only solution I figured out, was to change the VHOST configuration so that the logfile is getting saved in the folder of the project. But I ask this question out of interest if it also work if the logfile is in the apache2 log folder.

  • 1
    there's a very nice answer here explaining the points of subdirectory permissions and the different roles the read and execute permissions play on directories: Commented Dec 29, 2021 at 11:04
  • I'd go as far as saying that answers your question! Commented Dec 29, 2021 at 11:05

1 Answer 1


The answer Marcus linked explains very well how directory permissions work.

To answer the "How" for your specific case - as long as the log file you want everyone accessing itself has the correct permissions to indeed allow read-only or read-write access to itself, you can create a hardlink to the file in a central location accessible by those users.

ln /var/log/apache2/foo_error.log /path/to/user_accessible_dir/foo_error.log

Note that using a symbolic link will not work as it will be affected by the original file's parent directory permissions.

If you want to better understand the difference between hard links and symbolic links (and why this works) - see this answer: https://stackoverflow.com/a/185903/17508208

  • 3
    Also note that when log files get renamed and then recreated (e.g. logrotate might do something like that), the hardlink will still be to the original, moved file. Commented Dec 29, 2021 at 12:20

Not the answer you're looking for? Browse other questions tagged .