With reference to the answer in the this thread, I would like to ask about another case where we have to save important files in a folder above the document root to protect important user data ( say the user pics). I would like to ask as follows:-
- Is it good practice to save important user data files outside the document root?
- If yes, then what would be the best way to define file and folder permissions for such a folder so that apache can write and serve these securely while protecting the rest of the server.
Thanks.
Rephrasing my question after using the information received in reply to the above:
chown -R user:apache /var/www/mysite.com
with directory structure
( 750) (750)
/var/www/mysite.com/ html () (730)
\ internal\uploads\test.jpg (660)
\ (710)
\scripts\test.php (640)
\ (710)
\functions\fn.php (640)
DOCROOT is html. OUTSIDE DOCROOT is internals. uploads stores profile pics of users and need g+rw perms for files for user apache while folder uploads needs w_x perms.
Would you say that these permissions as shown in the folders structure are correct? With these permissions, should I be worried about the fact that apache traverses outside the root to write the files in uploads?
/var/www
for the given directory must be applied additional rules within the virtual host configuration. As reference inspect how the access to/usr/share
within the defaultapache2.conf
. – pa4080 May 08 '20 at 09:55