This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hello, I've been using October on a commercial site for two years. It has a lot of users and a lot of traffic. Suddenly, a month ago, and today again, October stopped serving the front end without any error in the browser, just a page telling the server was not responding, while the backend admin area was working properly. The error in the log is
Symfony\Component\Debug\Exception\FatalErrorException: Uncaught RuntimeException: Unable to write in the cache directory (/var/www/provedk/october/storage/cms/twig/5a). in /var/www/provedk/october/vendor/twig/twig/lib/Twig/Cache/Filesystem.php:59
Stack trace:
#0 /var/www/provedk/october/vendor/twig/twig/lib/Twig/Environment.php(369): Twig_Cache_Filesystem->write('/var/www/proved...', '<?php\n\n/* /var/...')
#1 /var/www/provedk/october/modules/cms/classes/Controller.php(374): Twig_Environment->loadTemplate('/var/www/proved...')
#2 /var/www/provedk/october/modules/cms/classes/Controller.php(211): Cms\Classes\Controller->runPage(Object(Cms\Classes\Page))
#3 /var/www/provedk/october/modules/system/classes/ErrorHandler.php(70): Cms\Classes\Controller->run('/error')
#4 /var/www/provedk/october/vendor/october/rain/src/Exception/ErrorHandler.php(58): System\Classes\ErrorHandler->handleCustomError()
#5 /var/www/provedk/october/modules/system/ServiceProvider.php(256): October\Rain\Exception\ErrorHandler->handleException(Object(RuntimeException))
#6 [internal function]: Sys in /var/www/provedk/october/vendor/twig/twig/lib/Twig/Cache/Filesystem.php:59
Stack trace:
#0 {main}
It turns out that the folder /var/www/provedk/october/storage/cms/twig/5a
was owned by root
, while other folders in the twig
subfolder were owned by www-data
as they are supposed to be.
How can this be? Why some of the newly created subfolders of the twig
folder are suddenly owned by root
?
Thanks
Could be a wide range of reasons.
I had a similar problem where i deleted a log file, normally this is not a huge issue since it gets recreated whenever something new gets logged. However our Cron job was running under the Root user ( big no no ) and it was the first to log an entry, causing the file to be created under root privileges which now shut down any attempt for the regular site to log.
Do you have any processes running as root which could trigger a twig cache?
I don't have an answer for you, but I have the same problem happen on a single server of mine about once a week. I tried tracking it down but couldn't figure out why it was happening. I ended up just running a cronjob that reset permissions every hour just in case until I found a Better solution.
Yeah, for me it was also a scheduled console command that was actually beeing run by the root user that lead to this error.
Thanks for all your suggestions guys. Obviously there is a root owned process that does something to the Twig cache folder, but for the life of me, I can't find what it is. @alxy do you perhaps remember what command was it that was messing your system?
I can't imagine a root process that would trigger creating a new Twig cache folder with root ownership.
Thanks again
Use ACL's to ensure that all relevant files and directories are writable by the http user even if someone else creates or copies a file.
I'd go in to more detail but I think it's beyond the scope of this forum and I don't want to assume anything about your setup. Have a look at https://linuxconfig.org/how-to-manage-acls-on-linux as a starting point.
Thanks, I did this, and it seems it works.
Rob Ballantyne (Dynamedia) said:
Use ACL's to ensure that all relevant files and directories are writable by the http user even if someone else creates or copies a file.
I'd go in to more detail but I think it's beyond the scope of this forum and I don't want to assume anything about your setup. Have a look at https://linuxconfig.org/how-to-manage-acls-on-linux as a starting point.
1-8 of 8