Want to add a user to upload files using FileZilla on Debian server

Hi

I would like to add a user to upload files using FileZilla on Debian server. I have added a user to www-data group and made him the owner of the webroot (/var/www) and I could upload files on to the server.

Now the problem is that the site could not upload images into server folders; obviously the user www-data under which Apache2 is running is no longer the owner of the root.

Could someone tell me how to find a way around it. Literally, can I have this user in www-data group with write/edit permission on the Webroot folder in addition to Apache2’s www-data user

Thanks

root      6485  0.0  1.2 287076 25196 ?        Ss   20:54   0:00 /usr/sbin/apache2 -k start
www-data  6489  0.0  1.3 289740 27284 ?        S    20:54   0:00 /usr/sbin/apache2 -k start
www-data  6490  0.0  1.2 288204 25812 ?        S    20:54   0:00 /usr/sbin/apache2 -k start
www-data  6491  0.0  1.4 289792 28664 ?        S    20:54   0:02 /usr/sbin/apache2 -k start
www-data  6492  0.0  1.2 289676 26276 ?        S    20:54   0:00 /usr/sbin/apache2 -k start
www-data  6496  0.0  1.4 291144 29232 ?        S    20:54   0:00 /usr/sbin/apache2 -k start
www-data  6497  0.0  1.1 288092 24348 ?        S    20:54   0:00 /usr/sbin/apache2 -k start
www-data  6498  0.0  1.3 290080 27084 ?        S    20:54   0:00 /usr/sbin/apache2 -k start
www-data  6499  0.0  1.3 290076 27804 ?        S    20:54   0:00 /usr/sbin/apache2 -k start

7 Replies

Hi BritWeb,

Generally speaking you want to be careful with how you modify permissions on files being served by a web server. If you can, I'd start by reverting back to the permissions you had.

One of the ways I get around this issue is by making my user a secondary group member of www-data:

sudo usermod -aG www-data myuser

And giving the group write access:

sudo chmod -R g+w /var/www/

Before you go messing with this further, you may want to read this

Many thanks for the advice and the link, alexfornuto. That's exactly what I was after.

Cheers!

~~![](<URL url=)https://media.giphy.com/media/mOOuUUIEEgq6A/giphy.gif" />

EDIT: P.S. I just realized that the chmod command I gave you was missing a "-R", for recursive.~~

@alexfornuto:

EDIT: P.S. I just realized that the chmod command I gave you was missing a "-R", for recursive.

Yes, I did notice that and included '-R' when I did it to apply the permission recursively to files & folders down and all is well.

Cheers!

Hi

Just realised that when I transferred files on to the server using FileZilla as the user that I added to www-data group (and the www-data has write permission to folders & files), the files show permission as -rw-r–r-- rather than -rw-rw-r– which I originally set up and the owner/group for those files show ftuser ftuser rather than www-data www-data.

How do I overcome this? I do not have to reset the permissions every time files were loaded, do I?

Kind regards

Make the group www-data (apache or whatevs) sticky on the directory. When a file is modified or put into a "sticky" directory the group ownership is inherited from the directory's parent rather than the user's group. Then you will, generally, chmod -R g+rx so the web server has permissions (based on group) after that it should maintain itself adding the appropriate group to new files. Anyone can be owner…we really only focus on the group to accomplish this task in this way.

Command: find /var/www -type d -exec chmod g+s {} \;

Explanation: http://superuser.com/questions/378412/e … in-var-www">http://superuser.com/questions/378412/editing-files-in-var-www (third post…more or less)

The owner of the files does not have be www-data for apache to work well. The requirement is that the apache server which runs as www-data must be able to read the files. Most systems default to allowing group read access, so having the group on the files be www-data is sufficient.

Thanks, jeremye77

Much appreciate your prompt reply and I will follow your post.

Regards

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct