问题
It was a cms and I would like to set all my files on server to -rw-------
This will make my website working as usual? or they will not read each other, for example i have this:
require_once 'include/checksession.php';
回答1:
First, you need to understand what each "segment" means.
- first triad what the owner can do
- second triad what the group members can do
- third triad what other users can do
Your permission set (-rw-------
) only has permissions on the first triad - the owner of the file - which only has read
and write
permissions.
- read The Read permission refers to a user's capability to read the contents of the file.
- write The Write permissions refer to a user's capability to write or modify a file or directory.
- execute The Execute permission affects a user's capability to execute a file or view the contents of a directory.
Therefore, the owner of the group can read the contents of the file/directory, write to the file/directory, and modify the file/directory.
Under careful file/directory ownership policies, I guess this will be okay - but I wouldn't count on it. If Apache/Nginx/... doesn't have ownership of the file, your application won't work.
This being said, I'd like to raise a few questions;
- Why change the permissions of all files/directories on your server?
- Why set a global permission rule, and not individual to each file/directory?
- What's the end-goal of this?
I'd take some consideration to Jon T's answer
回答2:
Depends on whether PHP is running as your user or as as something else (Apache, nobody etc)
If it runs as your user (using suexec or something similar), then nothing else needs to read PHP files.
I'd set these to 0600, giving only your user read/write access. Set to 0400 (read-only) for things like config files.
If you have mutiple FTP users accessing your files, then you need to allow group read/write access as well. Permissions then would be 0660.
If PHP is running as another user and it's not in a chroot'd environment, change your webhost.
Also, on a side note, if your CMS requires permissions anywhere of 0777 (I'm looking at you, Joomla), use a different CMS
来源:https://stackoverflow.com/questions/24612406/file-system-permissions