If you cannot install wordpress themes because you get the error “installation failed unable to create directory”, help is on the way

I just unpacked a fresh install of WordPress 5.2.1… at first I could not upload themes. But this was fixed by chmod 777 wp-content/uploads.

Then the themes installed via ftp would installed, giving me the error “could not create directory”. I fixed it by doing this:

Just login to your webserver. Then change directory to the root of the wordpress site. And type in the following incantation:

sudo chown -R www-data:www-data .

.. tada! And dont forget the dot at the end of that command.