I'm trying to build a local PHP server using XAMPP.
When I'm trying to run one of the PHP files, I get an error about the fopen command in the file.
From a quick search in the web, I've seen that in order to solve it I need to run this command on terminal:

sudo chmod 777 file.extension

On the comments to this article, I've seen that I should use 760 instead of 777.

My question is what every chmod command can do? Can it be a security problem? What do you recommend me to do?


See man chmod for what the command does. Basically it sets access permissions on files and folders, with the three digits standing for user, group and other permissions. So the first digit defines the permissions for the user owning the file, the second for the group owning the file, the third for anybody else.

In your case

  • chmod 777 gives everybody read, write and execute rights which for most problems is definitively too much
  • chmod 760 gives all rights to the owner, read and write to the group owning the file and no rights to users which neither own the file nor are part of the owning group

Granting too many rights might be a security problem, depending on whether other people can access your computer and/or your computer is accessible from outside.

To resolve apache/PHP issues, granting 777 seems to be rather broad. I would go with 664 (or even 660) first.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .