window window window window - 1 year ago 120
Linux Question

File permission in ubuntu

I have a VPS and use it for hosting my sites. The server is nginx with php-fdm.
my site is in the

and all the files and folders under the html directory owned by
www-data www-data
. All files permision is
and directories (html folder and sub-directories) has
permission. And also my user is member of the

I can change every files in this folder, but I can't make new file or new folder here. This need
privileges. I can create new file in the sub-directories like
but not in the
while they have the same owner and permission.

Answer Source

The user you are logging in as is not the www-data user or a member of the www-data group.

I set things up on my servers so that the user I log in as owns the files/directories, and a webuser group is the owning group, perms are set to 750/640. You can automagically keep the owning group the same across all files/directories uploaded to/created on the server by making the top level web directory setgid.

drwxr-s---  4 debbie www-data  4096 Oct  6  2015 /var/

If the webserver needs to write files, create the directory and change the permissions on it

sudo mkdir /var/
sudo chmod 770 /var/

If you haven't done the setgid thing, then fix the ownership

sudo chown debbie.www-data /var/

And there ya go, the web server user can write to it.

drwxrws---  4 debbie www-data  4096 Oct  6  2015 /var/
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download