cakephp SplFileInfo::openFile myapp_cake_core_cake_console 无法打开流:权限被拒绝

use*_*972 3 permissions cakephp

我在一个网站上工作了大约一个月,最近我尝试烘焙一些东西,现在我真的遇到了刚刚出现的缓存权限问题。我已经阅读了 stackoverflow 上有关此问题的所有内容,例如:

SplFileInfo::openFile(/app/tmp/cache/persistent/cake_core_cake_console_):无法打开流:/lib/.../FileEngine.php第293行中的权限被拒绝

Cakephp 权限被拒绝 Fileengine.php

包括错误/非错误: http://cakephp.lighthouseapp.com/projects/42648/tickets/2172

但我仍然无法阻止在使用 HTML->script helper 插件加载 javascript 资源期间出现此错误。

警告:SplFileInfo::openFile(/var/www/2tli/app/tmp/cache/persistent/myapp_cake_core_cake_console_):无法打开流:/var/www/2tli/lib/Cake/Cache/Engine/FileEngine 中的权限被拒绝。 php第314行

调用堆栈:0.0009 352948 1. {main}() /var/www/2tli/app/webroot/index.php:0

0.0045     446644   2. include('/var/www/2tli/lib/Cake/bootstrap.php') /var/www/2tli/app/webroot/index.php:92

0.0327    1174292   3. Configure::bootstrap() /var/www/2tli/lib/Cake/bootstrap.php:171

0.0427    1406772   4. include('/var/www/2tli/app/Config/core.php') /var/www/2tli/lib/Cake/Core/Configure.php:78

0.0494    1512200   5. Cache::config() /var/www/2tli/app/Config/core.php:336

0.0495    1512940   6. Cache::_buildEngine() /var/www/2tli/lib/Cake/Cache/Cache.php:136

0.0562    1635708   7. FileEngine->gc() /var/www/2tli/lib/Cake/Cache/Cache.php:169

0.0562    1635796   8. FileEngine->clear() /var/www/2tli/lib/Cake/Cache/Engine/FileEngine.php:102

0.0617    1637516   9. FileEngine->_setKey() /var/www/2tli/lib/Cake/Cache/Engine/FileEngine.php:236

0.0627    1657060  10. trigger_error() /var/www/2tli/lib/Cake/Cache/Engine/FileEngine.php:314
Run Code Online (Sandbox Code Playgroud)

我正在运行 PHP 5.3.10。蛋糕2.3.7。我的 bootstrap.php 中有以下内容:

// Setup a 'default' cache configuration for use in the application.
Cache::config('default', array('engine' => 'File', 'mask' => 0666));
Run Code Online (Sandbox Code Playgroud)

在 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 ));

    Cache::config('_cake_model_', array(
        'engine' => $engine,
        'prefix' => $prefix.'cake_model_',
        'path' => CACHE . 'models' . DS,
        'serialize' => ($engine === 'File'),
        'duration' => $duration,
        'mask' => 0666
));
Run Code Online (Sandbox Code Playgroud)

我的插件还有一个 bootstrap.php :

Cache::config('UserPlugin', array(
    'engine' => 'File',
    'duration'=> '+3 months',
    'path' => CACHE,
    'prefix' => 'UserPlugin_',
            'mask'=>0666
));
Run Code Online (Sandbox Code Playgroud)

我已将所有 app/tmp 文件和文件夹作为我的 apache 所有者 www-data 并设置为 777(我还尝试了 666 来匹配掩码)。

我也删除并重建了 app/tmp 目录。

有人有什么想法吗?

编辑:我不太知道该怎么做,但我注意到注释掉 Html->script helper 有时不会消除错误(并且原始 html 仍然显示脚本的包含)。所以我开始删除缓存并将缓存持续时间设置为 1 秒。只有偶尔它才会按预期运行,因为 html 似乎已被缓存。我发现要始终如一地使其按预期工作(无论是在行内注释还是注释外)的唯一方法是删除缓存并重新启动浏览器(firefox)。然后,每当我重新启动 Firefox 后再次放入 html->script 时,蛋糕就会工作而不会出现权限错误。我确信问题会再次出现,因为我似乎找不到根本原因。

Zom*_*ode 5

我发现 Bake 这样做的问题是持久缓存中的文件的权限受到限制。这意味着我的网站创建了它们(www-data),并且没有为我的控制台应用程序提供使用该文件的完整读/写/执行权限。

我通过更改该持久文件夹中文件的权限来修复此问题

cd ./app/tmp/cache/persistent/
sudo chmod 777 *  
Run Code Online (Sandbox Code Playgroud)

我必须使用 sudo,因为我不是文件的所有者;网站(www-data)是。

希望这对某人有帮助。