Define in wp_config file.
/var/www/html/Your-Project-File/wp-config.php
define( 'FS_METHOD', 'direct' );
chown – changes ownership of files/dirs. Ie. owner of the file/dir changes to the specified one, but it doesn’t modify permissions.
sudo chown -R www-data:www-data /var/www