Solution for "Error saving content" when saving an error page in SilverStripeSolution for "Error saving content" when saving an error page in SilverStripe

Posted February 25th, 2010 in SilverStripe

I was getting the error message "Error saving content" when publishing an error page in the SilverStripe CMS and couldn't work out why. The changes were being displayed in the front end so the error message seemed kind of odd.

Static files

Then when I was reading the SilverStripe book I learnt that error pages are cached as static files in the "assets" directory. From my understanding, the error pages are still served from the database and template files, but there's the provision for serving these static files should they be needed.

When clicking the normal "Save" button the file is not written to, so I wasn't getting the error message then. When I clicked the "Save and Publish" button I was getting the error. This is shown in the screenshot below:

error saving content in silverstripe

File permissions

I had copied the website from one Linux virtual machine to another, and the ownership of the files changed from "www-data" (the user Apache runs as on Debian) to "chris" as would be expected. However the file permissions were 0644 meaning the web server could not write to them and is the reason for the error.

Simply changing the file permissions to 0666 solved the issue. Alternatively change the ownership of the file to the correct user.

Changing the permissions:

chmod 0666 assets/error-404.html

Changing the ownership:

sudo chown www-data:www-data assets/error-404.html

"sudo" runs the command as the root user which needs to be done in order to change the ownership. If it doesn't work then you are best to stick with changing permissions.

www-data is the user and group the user runs as on Debian so it needs to reflect whatever the user runs as on the distribution you are running. www-data:www-data changes both the user and group at the same time.

If changing ownership instructions are all gobbledy-gook to you then following the changing the permissions instructions instead, as it's simpler.

Comments

blog comments powered by Disqus