Change owner:group recursively on everything in path
sudo chown -R www-data:www-data .
Change all the directories to 755 (drwxr-xr-x)
sudo find . -type d -exec chmod 755 {} \;
Change all the files to 644 (-rw-r--r--)
sudo find . -type f -exec chmod 644 {} \;
wp-config.php
sudo chmod 660 wp-config.php
.htaccess
sudo chmod 644 .htaccess
Add user ubuntu to group www-data
sudo usermod -aG www-data ubuntu
Add group writing ability
sudo chmod -R g+w /path/