Heroku PHP应用程序无法写入雪松堆栈上的文件系统

I have a couple Heroku CakePHP apps running on the cedar stack. My app is erroring out on every request when the cache engine tries to write out to a file.

[Sat Feb 09 05:56:51 2013] [error] [client x.x.x.x] PHP Fatal error: Uncaught exception 'CacheException' with message 'Cache engine _cake_core_ is not properly configured.' in /app/www/lib/Cake/Cache/Cache.php:165
Stack trace:
#0 /app/www/lib/Cake/Cache/Cache.php(135): Cache::_buildEngine('_cake_core_')
#1 /app/www/app/Config/core.php(277): Cache::config('_cake_core_', Array)
#2 /app/www/lib/Cake/Core/Configure.php(76): include('/app/www/app/Co...')
#3 /app/www/lib/Cake/bootstrap.php(163): Configure::bootstrap(true)
#4 /app/www/app/webroot/index.php(82): include('/app/www/lib/Ca...')
#5 {main}
thrown in /app/www/lib/Cake/Cache/Cache.php on line 165

2013-02-09T05:56:51+00:00 app[web.1]: [Sat Feb 09 05:56:51 2013] [error] [client x.x.x.x] PHP Warning: /app/www/app/tmp/cache/persistent/ is not writable in /app/www/lib/Cake/Cache/Engine/FileEngine.php on line 336

2013-02-09T05:56:51+00:00 app[web.1]: [Sat Feb 09 05:56:51 2013] [error] [client x.x.x.x] PHP Warning: _cake_core_ cache was unable to write 'cake_dev_en-us' to File cache in /app/www/lib/Cake/Cache/Cache.php on line 309

I thought dynos on the cedar stack have writable ephemeral filesystems. Why am I getting not writable errors, and what can I do to fix them?

Your best bet would be to configure an actual cache system like Memcahier or even Redis. While you can normally write to the dynos, you have limited space and it will be lost on restart, and cause issues if you're using more than one dyno.

This specific instance could be explained by limitations in the apache conf, or dir settings in the buildpack. I'm sure not all directories are writable. If you run 'heroku run bash' and get a shell into your app, does the directory exist, and what are its permissions?

This specific problem has nothing to do with Heroku.

CakePHP's default gitignore ignores the tmp directory. The tmp directory structure was never committed into my new app and therefore didn't exist when deployed to Heroku.

So, when starting a new CakePHP app, take care to actually commit the tmp directories into your repository.