I have vsftpd up and running on my Ubuntu server. This is a development server and I want to be able to FTP my code directly to the directory which Apache is serving out.
As most of you know, www-data is the Apache user and the www-data user needs to have permissions to the directory that Apache is serving out.
I didn't want to make www-data an FTP user as well, so what I did instead was create another user for use with FTP, and put both www-data and the new user in a new group called www.
I did a chown -R www-data:www *
to the directory that Apache is serving and it works mostly fine.
The issue comes in when I FTP upload a file that didn't previously exist in that directory. The owner gets set to my FTP user. I want the owner to get set to www-data and the group to get set to www whenever a new file gets uploaded.
Is there any way to do this with vsftpd?
I've been furiously googling around for hours, but I can't find a way to do it. Any help would be greatly appreciated.
Edit:
I just set up a couple of cron jobs to run every minute and set the permissions:
*/1 * * * * chown -R www-data:www /var/www
*/1 * * * * chmod -R g+rw /var/www
It works but it's kind of clunky, and there's a ~1 minute delay between me uploading new code and having it work when I hit F5 in my browser.
Best Answer
Read
man 2 chmod
, especially the part that says:You could probably use this to make all files created in the directory in the
www
group, and change your web server'sumask
value to022
To do this safely, read and reread
man 2 chmod
,man 2 open
,man 2 stat
and anything pointed to in the See Also: sections. Learn how Linux deals with file and directory permissions for fun and/or profit!Or, you could install
inoticoming - trigger actions when files hit an incoming directory
, and do your thing whenever a file hits.