Score:0

apache doesn't show files which have different owner

fr flag

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?

ezra-s avatar
ru flag
apache user www-data or whichever your httpd server is using should have the least amounf of access possible to files and directories. For directories Apache should access to present the data, they should have at least x permission (search) and for files, r permission at most. In cases like public_html like I said in another cooment, root:root 755 for directories and 644 for files should be fine.
Score:1
cn flag

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

Score:1
cn flag

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.
ezra-s avatar
ru flag
this is a terrible advice, precisely Apache processes should never have ownership of any kind to static files it serves if it can be avoided. root:root and permissions 755 for dirs and 644 for files would be just fine.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.