Access denied edit files via SFTP on Ubuntu after upload via Wordpress

Asked

Viewed 1,190 times

2

I have an Ubuntu VPS (LAMP) and manage PHP files from the folder www via SFTP.

I use Wordpress on my server, with it I upload folders and files and I can also delete them. Via Wordpress when I upload a new folder or file and later try to delete or edit the content of some file directly via SFTP the server returns me access denied. If I send the file or folder directly via SFTP the server allows smoothly.

Every time I upload a folder or file via Wordpress and need to change later manually the folder or files via SFTP, I need to run the following command so the server does not return me access denied:

sudo chown -R  usuario:www-data /var/www

Why does this happen? Have I set the permissions incorrectly? When I use Wordpress to upload it generates the folder and files with different permissions?

  • The web server user is not the same as FTP, basically. One possibility would be to change the permission of the whole directory or at the time of the upload, to allow a wider access. But beware of shared hosting, because there may be improper access between users.

1 answer

1

This is because your Apache is run by the user www-data and you are accessing the ftp by another user. Thus, they are different users and one is not allowed to change the file of the other.

You can add your user (used in ftp) to the same user group www-data and leave the permissions as 775 and 664 instead of 755 and 664 as they usually are. This allows writing to the whole group.

See more about chmod and permissions here: http://rberaldo.com.br/chmod-permissoes-em-sistemas-linux-e-unix-like/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.