I don't know if it is the safest method or not. But pasting this code in wp-config.php once solved my problem:
define('FS_METHOD', 'direct');
sudo chown -R www-data:www-data wp_site_rootsudo chmod -R g+rw wp_site_root
solved my problem.
Remember to set files and directories permission in this way:
chown -R www-data:www-data /var/wwwfind /var/www/ -type d -exec chmod 755 {} \;find /var/www/ -type f -exec chmod 644 {} \;