LoginSignup
18
20

More than 5 years have passed since last update.

CakePHPのキャッシュファイルのパーミッションエラーの対処法

Posted at

CakePHPで以下のようなエラーが出るときがある。

問題

Warning: SplFileInfo::openFile(/www/app/tmp/cache/persistent/cake_core_cake_console_) [splfileinfo.openfile]: failed to open stream: Permission denied in /www/lib/Cake/Cache/Engine/FileEngine.php

このエラーは、キャッシュファイルのパーミッションの設定によって、ファイル所有者とアクセスユーザーが異なるために発生する。

解決方法

umaskを設定することで解決する。

umaskとは

ファイルを作成するときにデフォルトで使用するパーミッション設定の事。

キャッシュファイルの設定を更新

core.phpにのキャッシュの設定に以下の記述を追加する。

'mask' => 0666
app/Config/core.php
Cache::config('_cake_core_', array(
    'engine' => $engine,
    'prefix' => $prefix . 'cake_core_',
    'path' => CACHE . 'persistent' . DS,
    'serialize' => ($engine === 'File'),
    'duration' => $duration,
    'mask' => 0666,
));
Cache::config('_cake_model_', array(
    'engine' => $engine,
    'prefix' => $prefix . 'cake_model_',
    'path' => CACHE . 'models' . DS,
    'serialize' => ($engine === 'File'),
    'duration' => $duration,
    'mask' => 0666,
));

これでエラーは出なくなるはず!

18
20
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
20