first, go to your wordpress path and then run this command
sudo chown www-data:www-data . -R
sudo find . -type d -exec chmod 755 {} \;
sudo find . -type f -exec chmod 644 {} \;
don't forget to change yourwordpressfolder to your real path wordpress folder