If you are running the Bitnami WordPress stack. unsing the Autoptimize plugin, and get the “Autoptimize cannot write to the cache directory” error, there is a simple solution that does not involve reinstalling the plugin.
If the folder permissions are not correct, you may get the following error from Autoptimize:
Autoptimize cannot write to the cache directory (/opt/bitnami/wordpress/wp-content/cache/autoptimize/), please fix to enable CSS/ JS optimization!
To solve this, some suggestions on the internet involve deleting the /autoptimize/ folder, deactivating (or deleting) the plugin, and then reactivating.
You do not need to do that!
You can solve the problem without deleting the existing cache and without reactivating or reinstalling the plugin. All that is necessary is to restore the proper WordPress filesystem permissions. But first, it’s probably a good idea to understand what permissions Bitnami uses for its WordPress stack.
Bitnami applies the following default permissions to WordPress files and directories:
- Files and directories are owned by the user bitnami and group daemon.
- Directories are configured with permissions 775 by default.
- Files are configured with permissions 664 by default.
- The wp-config.php file is configured with permissions 640.
To solve the Autoptimize cannot write to the cache directory when using Bitnami WordPress, all you need to do is restore the correct permissions via SSH with the commands below, replacing TARGET with the WordPress application folder:
sudo chown -R bitnami:daemon TARGET sudo find TARGET -type d -exec chmod 775 {} \; sudo find TARGET -type f -exec chmod 664 {} \; sudo chmod 640 TARGET/wp-config.php
Note that you need to change TARGET to the WordPress application folder. The simplest way to work this is to move yourself into the /stack/ folder (if you’re using the newest Bitnami WordPress stack) and then you can simply replace “TARGET” with “wordpress“.
Leave a Reply