Owner of uploads directory is `www-data` but this prevents FTP access via PHP scripts
14,402
That would be why, you need the 'write' permission to delete files. You have a couple of options here.
- chwon /var/www/mysite/uploads to www-data:mike and chmod to 775 (rwxrwxr-x)
- Create an ftp-write group and chown /var/www/mysite/uploads to www-data:ftp-write and chmod to 775
- just chmod to 775 (rwxrwxr-x) and leave mike as part of the www-data group
- set an acl on the folder for mike with
setfacl -m user:mike:rwx
- Create an ftp-write group, add mike and the group (as well as any other users that need these permissions with
setfacl -m group:<ftp_group>:rwx
Related videos on Youtube
Author by
Mike Moore
Updated on September 17, 2022Comments
-
Mike Moore over 1 year
To allow write access to Apache, I needed to
chown www-data:www-data /var/www/mysite/uploads
to my site's upload folder. This allows me to delete files from the folder viaunlink()
in a PHP script.Unfortunately, this prevents another PHP script, which uses FTP functions, from working. I think it is because the FTP user is
mike
and now that the uploads directory is owned bywww-data
,mike
cannot access it.I added
mike
to the groupwww-data
, but this does not fix the issue.Can somebody advise me on how to allow PHP FTP functions to work in addition to file deletion using PHP's
unlink()
function?-
Admin almost 14 yearswhat's the group permissions on /var/www/mysite/uploads set to?
-
Admin almost 14 years@Zypher: Group permissions for
/var/www/mysite/uploads
arer-s
-
Admin almost 14 years@letseatfood and in
/var/www/mysite
? -
Admin almost 14 years@jneves Group permissions for
/var/www/mysite
arer-s
-
-
Mike Moore almost 14 years#3 worked (
chmod 775 /var/www/mysite/uploads
and leavingmike
in the groupwww-data
). Is this an okay solution? -
Mike Moore almost 14 yearsWould you elaborate about the longterm fix that you mentioned?
-
Zypher almost 14 years@letseatfood: yep perfectly acceptable :) I listed them in no particular order.
-
Mike Moore almost 14 yearsOh, do you mean that I should create a user specifically for FTP that is in the group www-data?
-
Tony almost 14 yearsyes, that is the correct way to do so