CakePHP2、Shell動かしたらWarning: SplFileInfo::openFileとかエラー

以下の様なエラー

$ /usr/local/bin/php /path/to/cakephp/app/Console/cake.php initial_import -app /path/to/cakephp/app
PHP Warning:  SplFileInfo::openFile(/path/to/cakephp/app/tmp/cache/persistent/myapp_cake_core_file_map): failed to open stream: Permission denied in /path/to/cakephp/lib/Cake/Cache/Engine/FileEngine.php on line 355
Warning: SplFileInfo::openFile(/path/to/cakephp/app/tmp/cache/persistent/myapp_cake_core_file_map): failed to open stream: Permission denied in /path/to/cakephp/lib/Cake/Cache/Engine/FileEngine.php on line 355
Warning (512): SplFileInfo::openFile(/path/to/cakephp/app/tmp/cache/persistent/myapp_cake_core_object_map): failed to open stream: Permission denied [CORE/Cake/Cache/Engine/FileEngine.php, line 355]

Welcome to CakePHP v2.4.7 Console
---------------------------------------------------------------
App : app
Path: /path/to/cakephp/app/
---------------------------------------------------------------
2014-04-15 11:50:45 Error: 実行!
Warning Error: SplFileInfo::openFile(/path/to/cakephp/app/tmp/cache/persistent/myapp_cake_core_file_map): failed to open stream: Permission denied in [/path/to/cakephp/lib/Cake/Cache/Engine/FileEngine.php, line 355]
Warning Error: _cake_core_ cache was unable to write 'file_map' to File cache in [/path/to/cakephp/lib/Cake/Cache/Cache.php, line 323]
Warning Error: SplFileInfo::openFile(/path/to/cakephp/app/tmp/cache/persistent/myapp_cake_core_object_map): failed to open stream: Permission denied in [/path/to/cakephp/lib/Cake/Cache/Engine/FileEngine.php, line 355]
Warning Error: _cake_core_ cache was unable to write 'object_map' to File cache in [/path/to/cakephp/lib/Cake/Cache/Cache.php, line 323]

どうもパーミッション絡みのようだ

対策

Config/Core.phpに以下記述

/**
 * Configure the cache used for general framework caching. Path information,
 * object listings, and translation cache files are stored with this configuration.
 */
Cache::config('_cake_core_', array(
'engine' => $engine,
'prefix' => $prefix . 'cake_core_',
'path' => CACHE . 'persistent' . DS,
'serialize' => ($engine === 'File'),
'duration' => $duration,
'mask' => 0666 // ←ここ追加
));

/**
 * Configure the cache for model and datasource caches. This cache configuration
 * is used to store schema descriptions, and table listings in connections.
 */
Cache::config('_cake_model_', array(
'engine' => $engine,
'prefix' => $prefix . 'cake_model_',
'path' => CACHE . 'models' . DS,
'serialize' => ($engine === 'File'),
'duration' => $duration,
'mask' => 0666 // ←ここ追加
));

するとOK

$ /usr/local/bin/php /path/to/cakephp/app/Console/cake.php initial_import -app /path/to/cakephp/app


Welcome to CakePHP v2.4.7 Console
---------------------------------------------------------------
App : app
Path: /path/to/cakephp/app/
---------------------------------------------------------------
2014-04-15 12:07:44 Error: 実行!

参考

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です