Want to add a user to upload files using FileZilla on Debian server
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
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
~~![](<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!
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
Command: find /var/www -type d -exec chmod g+s {} \;
Explanation:
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.
Much appreciate your prompt reply and I will follow your post.
Regards