What is the correct folder permission for linux servers in production?

Asked

Viewed 664 times

3

Reading the manual of PHP and some tutorials I was in doubt about which permission to leave in the folders after uploads of images. Some tutorials tell to leave as 0755, others as 0750, which to use in this case for the security of the application and server on the web?

1st Example:

chmod ("/arquivo/diretorio", 0755);

2nd Example:

chmod ("/arquivo/diretorio", 0750);
  • 3

    There is not a single correct way. You have to understand how it works and use the one that suits your specific case. Copying from somewhere is a bad idea.

  • @Bacco, thank you for the reply, not leaving full access or be worth 0777 ta then? If you want to leave a reply!

  • 2

    The problem is that it depends on a whole series of things in the installation environment, it becomes complex an answer covering all cases. It depends on who is the Owner of the folder, depends on whether you want FTP access as well, you have to know who is the webserver user (which is usually the PHP user too), and so on. Each case is a case. In general, "the less the better" as long as the application works. If it works at 700, you don’t need 750, if you need 750, but it works well, you don’t need 755, but that’s a very big simplification. It has a lot of detail in "game". Better study and understand.

  • Got it, thanks!

  • Good, but had given a search before, came many but not this! But the link helped me a lot, thanks really. ;)

  • 1

    I marked the duplicate, because whoever searches this one will find the answer more detailed too, since the answer accepted is in the line of that other..

Show 1 more comment

1 answer

3


Permission is given as follows:

the first Octeto is the permission for the user (owner of the file), the second Octeto is for the group, the third Octeto is for all other users. It is important to leave minimal permission for unknown users to avoid server attacks.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.