I wrote a cakeshell script that I plan to use with cronjob. running it manually (during testing), sometimes my site will trigger a SplFileInfo warning, for example:
Warning: SplFileInfo::openFile(/var/www/flat/app/tmp/cache/persistent/myapp_cake_core_file_map):
failed to open stream: Permission denied in /var/www/flat/lib/Cake/Cache/Engine/FileEngine.php on line 313
Warning (512): SplFileInfo::openFile(/var/www/flat/app/tmp/cache/models/myapp_cake_model_default_flat_list):
failed to open stream: Permission denied [CORE/Cake/Cache/Engine/FileEngine.php, line 313]
Warning (512): SplFileInfo::openFile(/var/www/flat/app/tmp/cache/models/myapp_cake_model_default_flat_list) [http://php.net/splfileinfo.openfile]:
failed to open stream: Permission denied [CORE/Cake/Cache/Engine/FileEngine.php, line 313]
Warning (512): _cake_model_ cache was unable to write 'default_flat_list' to File cache [CORE/Cake/Cache/Cache.php, line 309]
Warning (512): SplFileInfo::openFile(/var/www/flat/app/tmp/cache/persistent/myapp_cake_core_method_cache) [http://php.net/splfileinfo.openfile]:
failed to open stream: Permission denied [CORE/Cake/Cache/Engine/FileEngine.php, line 313]
Warning (512): SplFileInfo::openFile(/var/www/flat/app/tmp/cache/persistent/myapp_cake_core_method_cache) [http://php.net/splfileinfo.openfile]:
failed to open stream: Permission denied [CORE/Cake/Cache/Engine/FileEngine.php, line 313]
Warning (512): SplFileInfo::openFile(/var/www/flat/app/tmp/cache/models/myapp_cake_model_default_flat_list) [http://php.net/splfileinfo.openfile]:
failed to open stream: Permission denied [CORE/Cake/Cache/Engine/FileEngine.php, line 313]
Warning (512): SplFileInfo::openFile(/var/www/flat/app/tmp/cache/models/myapp_cake_model_default_flat_list) [http://php.net/splfileinfo.openfile]:
failed to open stream: Permission denied [CORE/Cake/Cache/Engine/FileEngine.php, line 313]
Warning (512): _cake_model_ cache was unable to write 'default_flat_list' to File cache [CORE/Cake/Cache/Cache.php, line 309]
What happened? and how to fix it?
If I check the tmp directory for cache and persistent, some of the files are under root privileges. This is the reason?
[root@Apps103 persistent]# ls
total 40K
-rw-rw-r-- 1 apache 43 Apr 22 17:49 myapp_cake_core_cake_
-rw-rw-r-- 1 root 43 Apr 23 10:01 myapp_cake_core_cake_console_
-rw-rw-r-- 1 root 43 Apr 23 10:01 myapp_cake_core_cake_dev_
-rw-rw-r-- 1 apache 43 Apr 23 10:26 myapp_cake_core_cake_dev_en-us
-rw-rw-r-- 1 apache 43 Apr 23 10:26 myapp_cake_core_cake_en-us
-rw-rw-r-- 1 apache 43 Apr 23 10:26 myapp_cake_core_default_en-us
-rw-rw-r-- 1 root 4.3K Apr 23 10:01 myapp_cake_core_file_map
-rw-rw-r-- 1 root 4.3K Apr 23 10:01 myapp_cake_core_method_cache
I tried the solution at this link SplFileInfo :: openFile (/ app / tmp / cache / persistent / cake_core_cake_console _): could not open the stream: Permission denied in / lib /.../ FileEngine.php line 293
I put this in bootstrap
Cache::config('default', array(
'engine' => 'File',
'mask' => 0666,
));
Cache::config('short', array(
'engine' => 'File',
'duration' => '+1 hours',
'path' => CACHE,
'prefix' => 'cake_short_'
));
Cache::config('long', array(
'engine' => 'File',
'duration' => '+1 week',
'probability' => 100,
'path' => CACHE . 'long' . DS,
));
. tmp, . . , , , .
tmp (flat/app/tmp) apache.