Guides

I was doing some WordPress foo on the site (I know right, shockingly I don’t want to hand craft a website and I’d rather be helping customers or really anything else really) and I came into this error when I was installing the wpforms plugins:

 file_put_contents(/var/www/wordpress/wp-content/uploads/wpforms/cache/addons.json): failed to open stream: Permission denied in /var/www/wordpress/wp-content/plugins/wpforms-lite/src/Helpers/CacheBase.php on line 215

So I ssh into the server (after configuring a firewall rule to allow list a single IP) to get access. I’ve got ssh configured to use key based auth, which was fun when I was like… oooh what’s my passphrase (to the password manager I went) but in a few minutes “i’m in”.

Next up, let’s fix this. Now it sounds like a permissions error, so first thing I wanted to reset the permissions incase at some point I (or a another process) had changed anything so I ran the following:

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

sudo find /var/www/wordpress/ -type d -exec chmod 750 {} \;
sudo find /var/www/wordpress/ -type f -exec chmod 640 {} \;

Now permissions are reset, I head back into the admin console and de-activate and re-activate the plugins. Success! Hopefully that helps other people who might also have a similar error.