Secure chmod from php, html, css, js, png, folders?

I have a local host with files, all access rights are 777. but if I want to upload them to a real server, what is their correct safe resolution for each file type:

php, html, css, js, png and directories

Thank you very much

+4
source share
2 answers

On the server, it is most often recommended that the rights to directories be 755 and 644. Files in 777 permissions are not recommended for security reasons.

+3
source

Assuming you are using Apache and running it as an unprivileged user, the web server should be able to read and serve your content.

For directories, Apache requires both reading and execution. HTML, JS, CSS, and image files only require read permission. Executable scripts, such as PHP, require that both reading and execution be performed as intended. Therefore, for directories and PHP scripts, you want to use o+rx or in octal maybe 755 , depending on how you want to set the group ownership. And for non-executable content such as HTML, JS, CSS and image files, you must use o+r or 744 in octal format.

The eighth is a series of bit flags for owner , group and other , respectively. 1 corresponds to execute , 2 corresponds to write , and 4 corresponds to read .

To determine what a flag is, you add every bit for each group. Thus, 755 means that the owner has full permissions (1+2+4) , and the group and others have read and execute permissions (1+4) .

+5
source

Source: https://habr.com/ru/post/1483000/


All Articles