apache doesn't show files which have different owner [closed]

I have created a domain in WHM for user alex. now if I put any file in public_html folder of this domain which has the owner defined as root, apache does not allow visiting of the file in browser, it says not found. but if I change the owner of file to alex, everything works fine!

now I want apache to allow visiting every file in public_html, even if the owner is root and not alex. how to do that?


Apache run under www-data user. This user have certain privileges, but not enought to read root's files.

A solution is to add www-data group to files : chgrp www-data /path/to/files ; then adjust permission of files to allow group members to read these files : chmod g+r /path/to/files

An other solution, not really recommanded, is to allow other to read files : chmod o+r /path/to/files


now I want apache to allow visiting every file in public_html, even if the owner is root and not alex. how to do that?

Short answer: You can't.
Slightly longer answer: You shouldn't.

Learn about Linux File System permissions and how to work with them.
Trying to "force" your way around them will only give you trouble, later on.

I'd suggest that you:

  • Create a Group that contains the account running Apache and the one delivering the files,
  • Change the owning Group of the target directory to that Group,
  • Set the SetGID bit on that directory.