Short version : i can't upload images using php and i have no idea how to fix the permissions issue
Details :
I've been using a vps for around three years now
I set it up to run Sendy (a little newsletter/emailing script)
It is running debian 7
I created a user 'sendy' and the 'www' directory is inside the user folder
/home/sendy/www
The problem is that recently i wanted to start uploading uploading and i realized that the permissions are messed up.
This is what i get on error.log
[Thu Nov 14 12:43:38 2019] [error] [client xx.xxx.xx.xxx] (13)Permission denied: file permissions deny server access: /home/sendy/www/mail/uploads/1573731818.png, referer: http://example.com/mail/create?i=3
Any help is welcome.
Best Answer
Besides the fact the user "sandy" has the right permission to write in this own home directory (and subdirectories), the web server has an user of it own (usually www-data, nobody, apache, etc). That is the user that is going to do the writing operation.
So, check which user is running the web server daemon, change the ownership of the destination directory to that user and try again.
Considering the message you're mentioning, you should be able to fix with something like the following:
Or chow sendy:www-data /home/sendy/www/mail/uploads/ chomd -R g+w /home/sendy/www/mail/uploads/
Either way, we're allowing
www-data
to write into your directory. The first case assumes yoursendy
user doesn't need any access, the latter allows bothsendy
andwww-data
writing your uploads directory.