WordPress could not copy file

Fun fact: If you’re trying to add/update a theme or plugin and WordPress is giving you errors like “Could not copy files” or “Could not copy xxx.xxx” on a Linux (at least Ubuntu family) machine you should check your permissions.

When I moved the wordpress directory into the web root for Apache all of the files were owned by root. In order for WordPress to do its thing all of the files should be owned by the www-data user. You can fix this by using the chown command like so:

sudo chown -R www-data:www-data wordpress

…changing ‘wordpress’ of course to whatever your wordpress directory is named.  This will save you a ton of time and frustration.

Whatever you do don’t just chmod everything to 777.  Anyone who tells you to do that is not your real friend.